Search code examples
seleniumwebdriverwebdriver-io

Selenium Fluentwait implementation for Webdriver.io


Is there any FluentWait implementation available for WebdriverIO?

Looking for something similar to the Selenium Java FluentWait implementation, for example one below:

Wait wait = new FluentWait(WebDriver reference)
  .withTimeout(timeout, SECONDS)
  .pollingEvery(timeout, SECONDS)
  .ignoring(Exception.class);

WebElement foo=wait.until(new Function<WebDriver, WebElement>() {
  public WebElement apply(WebDriver driver) {
    return driver.findElement(By.id("foo"));
  }
});

I tried searching on various docs, but couldn't find an equivalent. Thanks!


Solution

  • You can use waitUntil api for that

        it('should wait until element is existing for 5000ms with 250ms polling', () => {
          browser.waitUntil(() => {
             return $('#someText').isExisting();  // condition
           }, 5000, 'expected element to be exist after 5s', 250);
        });
    

    it doesn't have ignore exception but maybe you can add try catch in condition function. But it will provide all the other functionalities.