Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Query
#1
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.
Reply
#2
Hi, If you want the block to be executed till the xyz.Exists...then i think it can be done in this way:
Code:
If (xyz.exists(0)) Then Do While (xyz.Exists(0)) Block of code: { statement 1 statement 2 " " " } Loop End If
Reply
#3
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
Reply
#4
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.
Reply
#5
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Rolleyes Browse object query Hema a newbie 0 2,152 07-22-2014, 08:37 PM
Last Post: Hema a newbie
  SQL Query Issue in QTP rajiv.qtp 1 2,939 11-28-2013, 10:36 AM
Last Post: Jay
  Do recordsets get to use only ONE query? Arena 0 2,470 04-03-2012, 07:08 PM
Last Post: Arena
  Pass "/" in Query string to DB Anjali09 0 2,898 01-04-2012, 08:34 PM
Last Post: Anjali09
  Database query ajayr1982 2 4,832 12-31-2010, 08:07 AM
Last Post: ajayr1982

Forum Jump:


Users browsing this thread: 1 Guest(s)