目录
流程控制系列简介
使您能够向测试中添加条件逻辑和循环。这使您能够仅在满足应用程序中的某些条件时执行命令(或一组命令),或根据预定义的条件重复执行命令。
相关方法
一共有以下几组:
if
,else if
,else
,end
times
,end
do
,repeat if
while
,end
- forech
官方API
if
Create a conditional branch in your test. Terminate the branch with the end command.
arguments
- conditional expression: JavaScript expression that returns a boolean result for use in control flow commands.
else
Part of an if block. Execute the commands in this branch when an if and/or else if condition are not met. Terminate the branch with the end command.
else if
Part of an if block. Execute the commands in this branch when an if condition has not been met. Terminate the branch with the end command.
arguments
- conditional expression: JavaScript expression that returns a boolean result for use in control flow commands.
end
Terminates a control flow block for if, while, and times.
times
Create a loop that executes the proceeding commands n number of times.
arguments
-
times: The number of attempts a times control flow loop will execute the commands within its block.
-
loop limit: An optional argument that specifies the maximum number of times a looping control flow command can execute. This protects against infinite loops. The defaults value is set to 1000.
do
Create a loop that executes the proceeding commands at least once. Terminate the branch with the repeat if command.
repeat if
Terminate a 'do' control flow branch conditionally. If the result of the provided conditional expression is true, it starts the do loop over. Otherwise it ends the loop.
arguments
- conditional expression: JavaScript expression that returns a boolean result for use in control flow commands.
while
Create a loop that executes the proceeding commands repeatedly for as long as the provided conditional expression is true.
arguments
-
conditional expression: JavaScript expression that returns a boolean result for use in contro