这里增加超时: mochaOpts: {ui: 'bdd',超时:100000},将 mocha 的默认等待时间更改为 100000 毫秒添加完成作为承诺解决it('should see product and version selected', () => {browser.url('//某个网址');browser.maximizeWindow();browser.waitUntil(() => {返回 $(ProductPage.productSelector()).isDisplayed()}, 100000, '预期页面已加载');让 productSelector = ProductPage.otherProductSelector();让 isEnabled = productSelector.isEnabled();if(isEnabled == true){const spanEle = $('//span[contains(text(),"text")]');isDisplayed = spanEle.isDisplayed();console.log(isDisplayed);assert.equal(isDisplayed, true, "Passed");}})错误:超时超过 100000 毫秒.对于异步测试和钩子,确保调用done()";如果返回 Promise,请确保它已解决. 解决方案 这里我从测试中删除了 browser.waitUntil(() => { .. } 语句,并添加了 WebdriverIO 提供的不同等待.似乎有与此方法中的 promise 返回相关的一些问题无法通过满足 promise 或任何其他方法来解决它.我有人知道,请在此答案中添加评论.以下是更多详细信息:https://github.com/webdriverio/webdriverio/issues/2361所以我改变的内容如下:it('should see product and version selected', () => {browser.url('url');browser.maximizeWindow();让 productSelector = $('#product-dropdown-toggle')让 isEnabled = productSelector.isEnabled();if(isEnabled == true){const spanEle = $('//span[contains(text(),"text")]');isDisplayed = spanEle.isDisplayed();console.log(isDisplayed);assert.equal(isDisplayed, true, "Passed");}}) waitForElemenDisplayed(element,timeout){element.waitForDisplayed(超时);}I have already seen this solution, but it did not help.I am trying to run webdriver.io tests using mocha, here I am using browser.waitUntil() method from webdriver.io, more details can be found here: https://webdriver.io/docs/api/browser/waitUntil.htmlI have tried a different solution to the issue including adding 'done' to the method call and also I am giving max timeout in conf.js as well here 10000ms, but still, the page seems to get hang on the result page.Here increase timeout: mochaOpts: { ui: 'bdd', timeout: 100000 },Changed default wait time of mocha to at 100000msAdded done as promise resolutionit('should see product and version selected', () => { browser.url('//some url'); browser.maximizeWindow(); browser.waitUntil(() => { return $(ProductPage.productSelector()).isDisplayed() }, 100000, 'expected page is loaded'); let productSelector = ProductPage.otherProductSelector(); let isEnabled = productSelector.isEnabled(); if(isEnabled == true){ const spanEle = $('//span[contains(text(),"text")]'); isDisplayed = spanEle.isDisplayed(); console.log(isDisplayed); assert.equal(isDisplayed, true, "Passed"); } })Error:Timeout of 100000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. 解决方案 Here I have removed browser.waitUntil(() => { .. } statement from the test and added different waits provided by the WebdriverIO. It seems there are some issues related to promise returning in this method was not able to resolve it by satifying promise or any other. I anyone knows please add a comment to this answer.Here are more details with this: https://github.com/webdriverio/webdriverio/issues/2361So what I have changed is as below:it('should see product and version selected', () => { browser.url('url'); browser.maximizeWindow(); let productSelector = $('#product-dropdown-toggle') let isEnabled = productSelector.isEnabled(); if(isEnabled == true){ const spanEle = $('//span[contains(text(),"text")]'); isDisplayed = spanEle.isDisplayed(); console.log(isDisplayed); assert.equal(isDisplayed, true, "Passed"); } }) waitForElemenDisplayed(element,timeout){ element.waitForDisplayed(timeout); } 这篇关于WebdriverIo 对于异步测试和钩子,确保“done()";叫做;如果返回 Promise,请确保它已解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-24 06:13