我通过一个 .suite 文件运行我的所有脚本,大致如下形式:
_include("variables.sah");
_include("functions.sah");
$a = 0;
while($a<3) {
try {
_navigateTo($loginpage);
login($user, $password);
myFunction();
$a = 3
}
catch (e){
_navigateTo($loginpage);
login($user, $password);
//undo changes made by myFunction()
...
$a++;
if($a<3) {
_log("Try again");
}
else {
_log("Skip to next script");
}
}
}
function myFunction() {
//do this
...
}
现在所有这些都运行得很好,除了一件事:当它遇到一个在正常情况下会中止所有脚本的缺失元素时它不会重复。它只是忽略错误并继续执行该套件的下一行。如果我不知道哪个部分(如果有)会失败以及何时失败,如何让我的脚本在继续之前重试 2 次?