Write and explain various loop command?

A for loop instructs WinRunner to execute one or more statements a specified number of times. It has the following syntax:
for ( [ expression1 ]; [ expression2 ]; [ expression3 ] )
statement
i. First, expression1 is executed. Next, expression2 is evaluated. If expression2 is true, statement is executed and expression3 is executed. The cycle is repeated as long as expression2 remains true. If expression2 is false, the for statement terminates and execution passes to the first statement immediately following.
ii. For example, the for loop below selects the file UI_TEST from the File Name list
iii. in the Open window. It selects this file five times and then stops. set_window ("Open")
for (i=0; i<5; i++)
list_select_item("File_Name:_1","UI_TEST"); #Item Number2
b. A while loop executes a block of statements for as long as a specified condition is true.
It has the following syntax:
while ( expression )
statement ;
i. While expression is true, the statement is executed. The loop ends when the expression is false. For example, the while statement below performs the same function as the for loop above.
set_window ("Open");
i=0;
while (i<5){
i++;
list_select_item ("File Name:_1", "UI_TEST"); # Item Number 2
}
c. A do/while loop executes a block of statements for as long as a specified condition is true. Unlike the for loop and while loop, a do/while loop tests the conditions at the end of the loop, not at the beginning. A do/while loop has the following syntax:
do
statement
while (expression);
i. The statement is executed and then the expression is evaluated. If the expression is true, then the cycle is repeated. If the expression is false, the cycle is not repeated.
ii. For example, the do/while statement below opens and closes the Order dialog box of Flight Reservation five times.
set_window ("Flight Reservation");
i=0;
do
{
menu_select_item ("File;Open Order...");
set_window ("Open Order");
button_press ("Cancel");
i++;
}
while (i<5);

Showing Answers 1 - 1 of 1 Answers

mukesh

  • Apr 10th, 2005
 

_select_item ("File;Open Order..."); 
set_window ("Open Order"); 
button_press ("Cancel"); 
i++; 

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions