Do...Loop statement
Relevant for: GUI actions, scripted GUI components, and function libraries
The Do...Loop statement instructs UFT One to perform a statement or series of statements while a condition is true or until a condition becomes true. It has the following syntax:
Do [{while} {until} condition] statement Loop
Item |
Description |
---|---|
condition |
A condition to be fulfilled. |
statement |
A statement or series of statements to be performed during the loop. |
Example: In the following example, UFT One calculates the factorial value of the price of a mouse using the Do...Loop:
Price = Browser("Advantage Shopping").Page("Advantage Shopping").WebElement("$9.99").GetTOProperty("innertext")
total = 1
i = 1
Do while i <= Price
total = total * i
i = i + 1
Loop
Msgbox "!"& Price & "="& total
Tip: Use the Edit > Code Snippet > Do...While or Edit > Code Snippet > Do...Until menu commands to automatically insert a statement into your test.