WaitForPagetoLoad equivalent command in webdriver

95 views
Skip to first unread message

Nagaraju Dasam

unread,
Apr 18, 2014, 6:14:59 AM4/18/14
to seleniu...@googlegroups.com, webd...@googlegroups.com
Hi Team,

I would like to know the equivalent webdriver comamnd for WaitForPagetoLoad.

I used below code:

public void waitForPageLoaded(WebDriver driver) {

     ExpectedCondition<Boolean> expectation = new
ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver driver) {
          return ((JavascriptExecutor)driver).executeScript("return document.readyState").equals("complete");
        }
      };

     Wait<WebDriver> wait = new WebDriverWait(driver,30);
      try {
              wait.until(expectation);
      } catch(Throwable error) {
              assertFalse("Timeout waiting for Page Load Request to complete.",true);
      }
 } 


But i am getting an issue with this below is error URL

Nagaraju Dasam

unread,
Apr 18, 2014, 6:15:20 AM4/18/14
to seleniu...@googlegroups.com, webd...@googlegroups.com

sunny sachdeva

unread,
Apr 28, 2014, 2:07:30 AM4/28/14
to webd...@googlegroups.com, seleniu...@googlegroups.com
I can suggest a workaround. For each page, why not wait for the last div to load.

Thanks
Sunny

erki manniste

unread,
Apr 28, 2014, 7:49:47 AM4/28/14
to webd...@googlegroups.com, seleniu...@googlegroups.com
driver.get() and driver.click() (last one in most cases) is already a blocking call, which means that among other things it checks for document.readyState to be complete , so I am afraid that the expected condition that you have implemented has no value whatsoever. Anyway, in my mind, the concept of "page has finished loading" does not anymore since the last days of static html or the days when JS was introduced. I mean, there is async stuff going on all the time.. That being said, if you are able to concretely define the moment when the page has finished loading, then wait for that very thing.

BR
erki.
Reply all
Reply to author
Forward
0 new messages