• Register
Win an IPAD!!! Checkout this page!
x

problem with ACTIONS in QTP plz HELP !!!

0 votes
I have recorded a test and have created 3 actions out of it
1>login
2>fax the order
3>logout

my question is i have used "if else" loops in login action to check the wrong name/password option, check point, report events etc

take a look and let me know what shud be the other condition.

login
--------
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").WinEdit("Agent Name:").Set DataTable("AgentName", dtGlobalSheet)
Dialog("Login").WinEdit("Password:").Set DataTable("password", dtGlobalSheet)
Dialog("Login").WinButton("OK").Click

if Dialog("Login").Dialog("Flight Reservations").Exist then
Dialog("Login").Dialog("Flight Reservations").Static("Please enter agent name").Output CheckPoint("error message")
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Cancel").Click
Reporter.ReportEvent micFail,"Login Failed","Incorrect Agent Name or Password"
else

-------------------------------------< what shud be the other condition here, that is when name/password is rite, should i call the fax the order here, is it possible to call the action of the same test in other action of the same test, if so plz let me know how to do>

end if

with out this condition the else loop will b incomplete, and it also wont continue executing other actions after this

1>login
2>fax order
3>logout

plz help, or if u have any other way plz let me know,thank you
asked Apr 18, 2012 by anonymous  
    

1 Answer

0 votes

Hi chindi,

Foremost , you have asked a very detailed question, which certianly helps while answering ... good work

Secondly,

In the else loop you can do the following

1) Directly record the code for fax order and logout
2) Record an Action say Fax Order in another script. "Call" this action in the above script . Same goes for logout. The entire process of call actions is detailed here - www.guru99.com/quick-test-professional-qtp-tutorial-18.html Please watch.

As a tip , I would recommend , you try approach 1 initially . Iron out errors and bugs in your script. Later you create a separate action and adopt a modular approach

Regards
Krish

answered Apr 18, 2012 by anonymous  
thanks krish, but sory am still not clear with it.
ya i have tried the first type u mention, wen i record all the 3 login, fax,logout directly then it works fine, but wat i need is i want to divide it in to 3 different action so tht i can call them any where i need, yes i have watched that video, ok let me make my point clear,
1> login action with checking both rite and wrong name/password
2>fax
3>logout

now, is there any other way to check the login fr rite and wrong name/password with out using if else loop? if so it would be useful,

am following all ur video, as the example u have give in that action tutorial, i want to make 2 tests, i.e.
test 1 with login,fax,logout
test2 with login, open order,logout

yes am able to do this as shown in ur tutorial, but i want the login to be more specific, with pass/fail status and error messages when wrong input is given, so i am using if else loop to make 2 condition, 1 wen its rite and 1 wen its wrong, this is not working fr me.. i want my input action to check fr both rite and wrong input then continue with the next action i.e fax, then continue with the 3 action tht is logout.

but i dont know what condition to give in the if else, look

if error message window exits then

click ok
click cancle

else

< what conditon shud i give to continue to the next action which i have already created separately>

end if

hope i am confusing u, if u have any method plz let me know, thank u so much fr replying.
Problem 1:

What you want is a driver script.

You open another test altogether and call the actions
1> login action with checking both rite and wrong name/password
2>fax
3>logout

in Order.

You will see a code something like Run Action. Will work

Problem 2:
If login is successful - you should continue to next action
If login fails - you should NOT continue to next action.

In the entire scheme of things , I gather that you a bit complicating the script and your logic is not clearly defined.

I recommend to complete all tutorials and later come back to more challenging scripts like these
ok thanku i will try this out, ya sure will go through all the tutorial and later will try this, thank u so much
...