jjstar 发表于 2005-9-22 11:15:04

请问winrunner中怎么加入循环 让一段操作重复执行?

请问winrunner中怎么加入循环 让一段操作重复执行?
新手 还不大会用 谢谢!:p

Tender 发表于 2005-9-22 11:19:19

可以在TSL中加入FOR语句,就可以循环了吧……

aswoon911 发表于 2005-9-28 20:34:30

TSL provides several statements that enable looping.

while ( expression )
        statement

While the expression is true, the statement is repeatedly executed. At the start of each repetition of the loop, the expression is evaluated; if it is true (nonzero or non-null), the statement is executed, and the expression is re-evaluated. The loop ends when the value of the expression is false.
Example

i = 1;
while (i < 21)
        type (i++);
types the value of i 20 times.
for ( [ expression1 ]; [ expression2 ]; [ expression3 ]; )
        statement

First, expression1 is implemented as the starting condition. While expression2 is true, the statement is executed, and expression3 is evaluated. The loop repeats until expression2 is found to be false. This statement is equivalent to:
expression1                                # state initial condition

while (expression2) {                        # while this is true
        statement                        # perform this statement and
        expression3                        # evaluate this expression
}

Example
The for loop below performs the same function as the while loop above.

for (i=1; i<21; i++)
        type (i);

Note that if expression2 is missing, it is always considered true, so that

for (i=1;;i++)
        type (i);
is an infinite loop.
do
        statement
while ( expression );

The statement is executed and then the expression is evaluated. If the expression is true, then the cycle is repeated. This statement differs from the while and for statements in that the expression is evaluated at the end. Therefore, the loop is always executed at least once.
In the following example, the structure of the loop ensures that the value of i is typed at least once:

i = 20;
do
        type (i++);
while (i < 17);

In the following example, there is a loop with more than one statement:

i = 20;
do        {
        pause (i);
        i++;
}
while (i < 17);

In the following example, there is an empty while statement:

while (expression);

Note that the expression is executed each time it's evaluated.
页: [1]
查看完整版本: 请问winrunner中怎么加入循环 让一段操作重复执行?