0

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.html I 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 100000ms Added done as promise resolution

it('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. 
halfer
  • 19,824
  • 17
  • 99
  • 186
web-auto-bot
  • 63
  • 2
  • 11

2 Answers2

0
it('should see product and version selected', (done) => {
    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");
    }

    done();
})

Only thing i can think of is that done was not passed in for the test call back at

it('should see product and version selected', (done) => {})

and then called at the very end. There isn't anything in your test that returns a promise.

Andrew Nolan
  • 1,987
  • 2
  • 20
  • 23
0

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/2361

So 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);
    }
web-auto-bot
  • 63
  • 2
  • 11