Posts: 11
Threads: 9
Joined: Jun 2010
Reputation:
0
10-05-2010, 05:21 PM
I have the following query:
Block of code:
{
statement 1
statement 2
"
"
"
}
if ....exist
execute the block of code again
How do I implement this in QTP? the block of code should be executed only once and again if the if condition becomes true.
Posts: 350
Threads: 2
Joined: Mar 2008
Reputation:
0
10-05-2010, 11:23 PM
Hi,
Here comes the concept of "Reusablity" into the picture.
Your 'block of code' by nature is reusable since it has to be called & executed whenever required condition become true.
So the block of statements should be converted to any one of below and called wherever applicable.
1. Userdefined Function
2. Reusable Action
Posts: 5
Threads: 1
Joined: Oct 2010
Reputation:
0
10-06-2010, 05:26 PM
I would suggest you to write the block of code in a flat file like .vbs file in a function and call the function whenever required.
Posts: 99
Threads: 0
Joined: Oct 2010
Reputation:
0
10-06-2010, 05:58 PM
Yes as Sreekanth said, If u want the script to be executed once and on some conditions, you can call user defined function as:
Write the block of code in text file, save as xyz.vbs, add it in settings and call it inside If statement as:
If (Condition) Then
Call xyz()
End If
OR
Write the block in reusable "action2" and run that action inside the main action
If (Condition) Then
RunAction "Action2", oneIteration
End If