Webdriver.waitUntil 没有按预期工作
Webdriver.waitUntil doesn't work as expected
我正在使用 wedriverio 4.5:
./node_modules/.bin/wdio -v
v4.5.2
我需要等到某个元素存在,如果它不存在则处理这种情况。
例如:
let element = browser.element('.unexisting');
browser.waitUntil(
function () {
return element.isExisting();
},
1000,
'Element is not found.'
);
但是如果页面上不存在元素,webdriver 会将我的测试标记为失败并显示消息:'Timeout of 10000ms exceeded. Try to reduce the run time or increase your timeout for test specs (http://webdriver.io/guide/testrunner/timeouts.html); if returning a Promise, ensure it resolves.'
我该如何处理这种情况?
- 我尝试了 try-catch 块,但无论如何我都看到关于超时和测试失败的相同消息。
- 我试过 element.waitForExist() 但行为是一样的
- 我尝试使用错误处理程序(但没有帮助)
browser.on('error', 函数(e) {
console.log ('handle browser error');
})
为什么我看不到我的消息 'Element is not found.'?
谢谢!
确保您的 waitForXXX 命令不会超过您的规范超时时间。如果它确实增加了您的规范超时,在您的情况下 mochaOpts.timeout。在这里查看更多 http://webdriver.io/guide/testrunner/timeouts.html#Framework-related-timeouts
我正在使用 wedriverio 4.5:
./node_modules/.bin/wdio -v
v4.5.2
我需要等到某个元素存在,如果它不存在则处理这种情况。
例如:
let element = browser.element('.unexisting');
browser.waitUntil(
function () {
return element.isExisting();
},
1000,
'Element is not found.'
);
但是如果页面上不存在元素,webdriver 会将我的测试标记为失败并显示消息:'Timeout of 10000ms exceeded. Try to reduce the run time or increase your timeout for test specs (http://webdriver.io/guide/testrunner/timeouts.html); if returning a Promise, ensure it resolves.'
我该如何处理这种情况?
- 我尝试了 try-catch 块,但无论如何我都看到关于超时和测试失败的相同消息。
- 我试过 element.waitForExist() 但行为是一样的
- 我尝试使用错误处理程序(但没有帮助)
browser.on('error', 函数(e) { console.log ('handle browser error'); })
为什么我看不到我的消息 'Element is not found.'?
谢谢!
确保您的 waitForXXX 命令不会超过您的规范超时时间。如果它确实增加了您的规范超时,在您的情况下 mochaOpts.timeout。在这里查看更多 http://webdriver.io/guide/testrunner/timeouts.html#Framework-related-timeouts