Bhoomiputra
Bhoomiputra

Reputation: 71

Wrapping browser.WaitUntil () Using Await and Async

I have to use async and await everywhere in my code. How can I get the code below to work with async/await? The code below results in a timeout.

await browser.waitUntil(
     async () => (await (await selector).getAttribute("value")) === pricePerUnit

The origin code worked just fine.

selector.setValue(selection)
    browser.waitUntil(() => {
      return selector.getAttribute('value') === selection
    })

Upvotes: 0

Views: 1962

Answers (1)

vlatko606
vlatko606

Reputation: 1149

Try this:

await browser.waitUntil(
    async () => (await $('#someText').getText()) === 'I am now different',
    {
        timeout: 5000,
        timeoutMsg: 'expected text to be different after 5s'
    }
);

Upvotes: 1

Related Questions