webdriverio wait for page to load

Viewed 12113

Is there a way to make webdriverio wait for a page to load? I saw that in java I can have something like:

executeScript("return document.readyState").equals("complete"));

or

driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

Is there a way I can do it in webdriverio? I know that I can use waits to wait for a specific element but I am looking for a way to wait for the whole page the load

3 Answers

simplified version of @ Sadeesh code:

browser.waitUntil(
  () => browser.execute(() => document.readyState === 'complete'),
  {
    timeout: 60 * 1000, // 60 seconds
    timeoutMsg: 'Message on failure'
  }
);
Related