如果nightwatch没有点击元素,我想重试。我怎样才能做到这一点?
我有以下代码:
this.browser.isVisible('.signUp', function (result) {
if (result.value && result.length) {
for(var i = 0; i < 3; i += 1) {
this.browser.click(this.element.login.signInBtn);
var check = this.browser.url(function(result) {
// on login page
console.log(result);
if (result.value.indexOf("#login") !== -1) {
return false;
} else {
return true;
}
});
if (check) {
break;
}
}
}
}.bind(this));
答案 0 :(得分:0)
您可以使用--retries命令行选项重试测试用例。示例name := "jsonApi"
organization := "com.github.kondaurovdev"
version := "0.1-SNAPSHOT"
scalaVersion := "2.11.7"
将再次重试失败的测试用例。
但是我不会建议你使用它。我首先会探索其他选项,以确保可以单击该元素。就像使用waitForElementVisible
等待它变得可见的示例 > publishLocal
[info] Packaging /home/user256/Projects/kondaurov/jsonApi/target/scala-2.11/jsonapi_2.11-0.1-SNAPSHOT-sources.jar ...
[info] Wrote /home/user256/Projects/kondaurov/jsonApi/target/scala-2.11/jsonapi_2.11-0.1-SNAPSHOT.pom
[info] :: delivering :: com.github.kondaurovdev#jsonapi_2.11;0.1-SNAPSHOT :: 0.1-SNAPSHOT :: integration :: Mon May 16 12:07:08 MSK 2016
[info] Done packaging.
[info] delivering ivy file to /home/user256/Projects/kondaurov/jsonApi/target/scala-2.11/ivy-0.1-SNAPSHOT.xml
[info] Main Scala API documentation to /home/user256/Projects/kondaurov/jsonApi/target/scala-2.11/api...
[info] Compiling 51 Scala sources to /home/user256/Projects/kondaurov/jsonApi/target/scala-2.11/classes...
model contains 97 documentable templates
[info] Main Scala API documentation successful.
[info] Packaging /home/user256/Projects/kondaurov/jsonApi/target/scala-2.11/jsonapi_2.11-0.1-SNAPSHOT-javadoc.jar ...
[info] Done packaging.
[info] Packaging /home/user256/Projects/kondaurov/jsonApi/target/scala-2.11/jsonapi_2.11-0.1-SNAPSHOT.jar ...
[info] Done packaging.
[info] published jsonapi_2.11 to /home/user256/.ivy2/local/com.github.kondaurovdev/jsonapi_2.11/0.1-SNAPSHOT/poms/jsonapi_2.11.pom
[info] published jsonapi_2.11 to /home/user256/.ivy2/local/com.github.kondaurovdev/jsonapi_2.11/0.1-SNAPSHOT/jars/jsonapi_2.11.jar
[info] published jsonapi_2.11 to /home/user256/.ivy2/local/com.github.kondaurovdev/jsonapi_2.11/0.1-SNAPSHOT/srcs/jsonapi_2.11-sources.jar
[info] published jsonapi_2.11 to /home/user256/.ivy2/local/com.github.kondaurovdev/jsonapi_2.11/0.1-SNAPSHOT/docs/jsonapi_2.11-javadoc.jar
[info] published ivy to /home/user256/.ivy2/local/com.github.kondaurovdev/jsonapi_2.11/0.1-SNAPSHOT/ivys/ivy.xml
答案 1 :(得分:0)
-retries n不会在函数之前和之后运行,因此这将无法按预期工作。你应该试试--suiteRetries n。