Webdriver.io:isExisting().then()不是函数
Webdriver.io: isExisting().then() is not a function
我想检查是否有logout元素。如果它已经存在,我想通过点击这个元素来注销:
browser.isExisting('.logout').then(function() {
browser.click('.logout');
});
但这给了我一个Uncaught TypeError: browser.isExisting(...).then is not a function
-错误。
如果您使用的是<4,你想要这个。http://webdriver.io/v3.4/api/utility/waitForExist.html
browser.waitForExist('.logout').then(function() {
browser.click('.logout');
});
但如果使用V4+,则所有内容都是同步的(http://webdriver.io/guide/getstarted/v4.html),并且您需要重写一点。http://webdriver.io/api/utility/waitForExist.html
像这样的
var logout = browser.element('.logout');
logout.waitForExist(5000);
browser.click('.logout');
您可以在这里查看:http://webdriver.io/api/state/isExisting.html
client.isExisting(selector);
返回布尔值。所以你的代码应该是这样的:
browser.isExisting('.logout').then(function(exist) {
if (exist) {
browser.click('.logout');
}
});
重写它以使用对象
browser.$('.logout').isExisting().then(function() {
browser.click('.logout');
});
https://webdriver.io/docs/api/element/isExisting.html您使用5.0 webdriver.io 的4.0语法
检查https://github.com/webdriverio/webdriverio/blob/master/CHANGELOG.md#v500-2018-12-20了解更多
相关文章:
- Javascript:If-then语句在函数中不起作用
- Promise函数在.then之后未运行函数化
- 如何在异步函数中正确使用Promise.all()和then()
- $resource上带有.then()函数的角度自定义方法导致错误
- 当链接javascript承诺时,如何处理then()函数中的条件
- 角承诺的“then”函数的成功回调的词汇范围是什么?
- “未捕获(在承诺中)”在获取“then”方法中调用拒绝函数时
- TypeError:元素(..).then不是Protractor 3.2.1中的函数
- AngularJS http.jsonp请求.then和.success函数不起作用
- 我的函数跳过if-then-else语句
- Node.js中的Promise.all没有't调用then函数
- Dispatch()调用一个函数,但是.then()不调用;我不在React Redux上工作
- 未捕获的类型错误:调用函数时无法读取未定义的属性“then”
- q 从 .then 函数分配给更高级别的作用域变量是否存在任何陷阱
- 当承诺在监视函数中解析时,如何使承诺的 then 函数起作用
- CasperJs then() 是否等待上一个函数中发出的事件
- 如何使 then 函数工作
- 取消以下“then”函数中的$timeout是否有效
- Ember 是否有总是回调.js .then 函数
- 然后 .then() 函数似乎在承诺完成之前运行