user2451016
user2451016

Reputation: 1961

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!

Upvotes: 2

Views: 581

Answers (1)

Yogendra Porwal
Yogendra Porwal

Reputation: 119

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.

Upvotes: 1

Related Questions