admin管理员组文章数量:1425752
I would like to check if there is a logout element. If it is existing, I want to do the logout by clicking this element:
browser.isExisting('.logout').then(function() {
browser.click('.logout');
});
But this gives me an Uncaught TypeError: browser.isExisting(...).then is not a function
-error.
I would like to check if there is a logout element. If it is existing, I want to do the logout by clicking this element:
browser.isExisting('.logout').then(function() {
browser.click('.logout');
});
But this gives me an Uncaught TypeError: browser.isExisting(...).then is not a function
-error.
-
Is the purpose of your code is that you want to ensure that
.logout
exists before clicking on it? – garajo Commented Aug 5, 2016 at 8:23
3 Answers
Reset to default 2If your using a version <4, you want this. http://webdriver.io/v3.4/api/utility/waitForExist.html
browser.waitForExist('.logout').then(function() {
browser.click('.logout');
});
But if you use V4+, everything is synchronous ( http://webdriver.io/guide/getstarted/v4.html ), and you would need to rewrite a bit. http://webdriver.io/api/utility/waitForExist.html
Something like this
var logout = browser.element('.logout');
logout.waitForExist(5000);
browser.click('.logout');
Rewrite it to use object
browser.$('.logout').isExisting().then(function() {
browser.click('.logout');
});
https://webdriver.io/docs/api/element/isExisting.html You using 4.0 syntax for 5.0 webdriver.io
Check https://github./webdriverio/webdriverio/blob/master/CHANGELOG.md#v500-2018-12-20 for more
You can look here: http://webdriver.io/api/state/isExisting.html
client.isExisting(selector);
Returns boolean. So your code should look something like this:
browser.isExisting('.logout').then(function(exist) {
if (exist) {
browser.click('.logout');
}
});
本文标签: javascriptWebdriverio isExisting()then() is not a functionStack Overflow
版权声明:本文标题:javascript - Webdriver.io: isExisting().then() is not a function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745390137a2656559.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论