Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controlling Actions
#1
Solved: 10 Years, 9 Months, 1 Week ago
Hi,

I have a test with 5 actions starting with "Login" action and ending with "Close" action. The "Login" action is parametrized with 2 id's where QTP can login to the application using these 2 ID's. There is one action in the test that should not be executed when QTP comes to Login ID 2.

For example, there are two ID's: UserA and UserB and there are 5 actions: Login, Sort, Print, Query, Close. UserA can execute all 5 actions in the test whereas UserB should not touch the Print action. How do I control this? Any ideas?
Reply
#2
Solved: 10 Years, 9 Months, 1 Week ago
Hi,
Its possible to contoll the acitons.
First save the test which contains your 5 actions, then go to the local path of the script (i.e. C:\test\), open the script folder. you can find total 6 action folders there like Action0...Action5
open Action0-->open script file(notepad file) ->follow the below steps and save the script and run in QTP

Suppose if you dont want to execute Action2 in second Iteration
use the below script:

'################
Code:
RunAction "Action1", oneIteration
     'I have used Environment variable to get the Test Iteration

     temp=Environment("TestIteration")
     '## for second iteration condition get fail & it won't execute second Action
     if temp<>2 then       RunAction "Action2", oneIteration
     End If

     RunAction "Action3", oneIteration
     RunAction "Action4", oneIteration
     RunAction "Action5", oneIteration
'#########################


Regards
KrishDeep
Chennai
Reply
#3
Solved: 10 Years, 9 Months, 1 Week ago
Hi,

I tried the method that you told me and it didn't work for me. Do you have any other method where I can integrate the IF statement in the actions.

I don't know how to introduce an IF statement in VB and I am hoping if you could give me an idea on how to do it. This is my script from Login Action:

Code:
Browser("ExxonMobil Authentication").Page("ExxonMobil Authentication").WebEdit("username").Set DataTable("username", dtGlobalSheet)
Browser("ExxonMobil Authentication").Page("ExxonMobil Authentication").WebEdit("password").SetSecure DataTable("pwd", dtGlobalSheet)
Browser("ExxonMobil Authentication").Page("ExxonMobil Authentication").WebButton("Login").Click
Browser("ExxonMobil Authentication").Page("Imperial Oil Limited").Sync

The Global Sheet has 2 usernames and passwords: UserA and UserB.

And this is my script for Print Action:

'This action only views the report

Code:
Browser("Imperial Oil Limited").Page("Imperial Oil Limited").Frame("_sweview").Link("Print").Click
Browser("Reports").Page("Reports").WebList("s_0_1_7_0").Select DataTable("Report_Name", dtLocalSheet)
Browser("Reports").Page("Reports").Link("Run Now").Click
Browser("Reports").Page("Page").Sync
wait(10)
Browser("Reports").Close
Browser("Imperial Oil Limited").Page("Imperial Oil Limited").Sync

Do you have any ideas on putting an IF statement? Please let me know. Thanks

Mahadevan Swamy
Reply
#4
Solved: 10 Years, 9 Months, 1 Week ago
I have tried this method but it doesnt work:

Login Script:

Code:
Browser("ExxonMobil Authentication").Page("ExxonMobil Authentication").Sync
Browser("ExxonMobil Authentication").Page("ExxonMobil Authentication").WebEdit("username").Set DataTable("username", dtGlobalSheet)
user = Browser("ExxonMobil Authentication").Page("ExxonMobil Authentication").WebEdit("username").GetROProperty(DataTable("username", dtGlobalSheet))

Browser("ExxonMobil Authentication").Page("ExxonMobil Authentication").WebEdit("password").SetSecure DataTable("pwd", dtGlobalSheet)
Browser("ExxonMobil Authentication").Page("ExxonMobil Authentication").WebButton("Login").Click
Browser("ExxonMobil Authentication").Page("Imperial Oil Limited").Sync


Print Script:

'This action only views the report

Code:
If user = "UserB" Then
msgbox "This action cannot be executed"

Else
Browser("Imperial Oil Limited").Page("Imperial Oil Limited").Frame("_sweview").Link("Print").Click
Browser("Reports").Page("Reports").WebList("s_0_1_7_0").Select DataTable("Report_Name", dtLocalSheet)
Browser("Reports").Page("Reports").Link("Run Now").Click
Browser("Reports").Page("Page").Sync
wait(10)
Browser("Reports").Close
Browser("Imperial Oil Limited").Page("Imperial Oil Limited").Sync
End if

Can anybody tell me how to make this work? Thanks
Reply
#5
Solved: 10 Years, 9 Months, 1 Week ago
Hi,
Try the following script...
Write this script in Login Action..
Code:
If DataTable("username",dtGlobalSheet) = "UserA" then

RunAction "sort", oneIteration
RunAction "Print", oneIteration
RunAction "Query", oneIteration
RunAction "Close", oneIteration

ElseIf DataTable("username",dtGlobalSheet) = "UserB" Then

RunAction "sort", oneIteration
RunAction "Query", oneIteration
RunAction "Close", oneIteration

End  If
Reply
#6
Solved: 10 Years, 9 Months, 1 Week ago
Hi,

I have tried the script that you are telling me. However there is one small problem. In the Login Action, when we use IF statements and call to the existing actions, at the very end we have this: RunAction "Close", oneIteration which closes the application. Then after the Login action, QTP runs the sort action and when the application is closed, testing error happens. Your idea is right and I used this code If DataTable("username",dtGlobalSheet) = "UserB" in the print action to restrict this action to A only. It is working. Thanks for the idea Wink
Reply
#7
Solved: 10 Years, 9 Months, 1 Week ago
Hi,
At the end use ExitRun(). this will stop the executions
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)