WaitForPagetoLoad in WebDriver

8,181 views
Skip to first unread message

Kumar

unread,
Aug 13, 2012, 9:45:33 AM8/13/12
to seleniu...@googlegroups.com
Hi,

Do we have any way to accomplish the waitforpagetoload with Selenium WebDriver?

Thanks,
Kumar

Mark Collin

unread,
Aug 13, 2012, 9:52:21 AM8/13/12
to seleniu...@googlegroups.com

WebDriver automatically waits for the page to load.  Of course your idea of the page loading may be different to WebDriver’s so the best thing to do is put in an explicit wait for a know element to appear if you are having problems.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/BHH40pUPNlcJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Alok Agarwal

unread,
Aug 13, 2012, 10:00:43 AM8/13/12
to seleniu...@googlegroups.com
Yes, thats correct.

I want for an element to appear.

How do I accomplish that?

Can you please assist?

Thanks,
Kumar

Mark Collin

unread,
Aug 14, 2012, 4:42:31 AM8/14/12
to seleniu...@googlegroups.com

Assuming you are using Java you can use the WebDriverWait class with ExpectedConditions:

 

//Wait up to 10 seconds for a condition

WebDriverWait waiting = new WebDriverWait(driver, 10);

waiting.until(ExpectedConditions.presenceOfElementLocated(By.id("myElement")));

Kumar

unread,
Aug 14, 2012, 6:28:43 AM8/14/12
to seleniu...@googlegroups.com
Thanks a lot Mark.

It worked really well and saves a lot of time.

Regards,
Kumar

gouse basha

unread,
Aug 14, 2012, 10:11:56 AM8/14/12
to seleniu...@googlegroups.com
The following function will wait till any element is visible (other than empty space) in the page. This helps if you are not sure for which element you need to wait.

public static boolean Wait_pageLoad( long seconds){
WebDriverWait wait = new WebDriverWait(getSeleniumObject(), seconds);
return wait.until(visibilityOfElementLocated( By.xpath("//*[not (.='')]")));
}

Regards,
Basha.

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/N0y4kjTcNK4J.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Thanks & Regards,
Basha
9538029173

Reply all
Reply to author
Forward
0 new messages