51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 2184|回复: 2

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

[复制链接]

该用户从未签到

发表于 2005-9-22 11:15:04 | 显示全部楼层 |阅读模式
请问winrunner中怎么加入循环 让一段操作重复执行?
新手 还不大会用 谢谢!:p
回复

使用道具 举报

该用户从未签到

发表于 2005-9-22 11:19:19 | 显示全部楼层
可以在TSL中加入FOR语句,就可以循环了吧……
回复 支持 反对

使用道具 举报

该用户从未签到

发表于 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 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-3-29 16:46 , Processed in 0.083216 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表