Need Selenium to wait until the document is ready.

0 votes

Does anyone know how to make selenium wait until the page loads completely? I want something simple which can be used else where also because I'm not a very technical person and I have like 1000 pages to test. So probably need to wait for sometime and move to test the next page.

So I got something in .net. But I want something similar for Java. 

IWait<IWebDriver> wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(30.00));
wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete"));

Any thoughts anyone?

Apr 20, 2018 in Selenium by kappa3010
• 2,070 points
2,730 views

1 answer to this question.

0 votes

Use this:

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

This piece of code will make your WebDriver wait up to 10 seconds for all elements in the page to load completely. If beyond this time the element is not found, then an exception called 'TimeoutException' will be thrown. 

This technique is called an implicit wait.

answered Apr 20, 2018 by king_kenny
• 3,650 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

Is it possible to manually set the attribute value of a Web Element using Selenium?

Yes, its very much possible. You just ...READ MORE

answered May 8, 2018 in Selenium by king_kenny
• 3,650 points
7,541 views
0 votes
1 answer

I need to release the memeory allocated to Selenium chromedriver.exe while for tests

The usage of the commands is incorrect. driver.close() ...READ MORE

answered May 21, 2018 in Selenium by sniffy_god
• 780 points
1,009 views
0 votes
2 answers
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
1,166 views
0 votes
1 answer

Impilicit wait vs Explicit wait vs Fluent wait

Implicit wait: Your telling the WebDriver the ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,650 points
1,032 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

C# and Selenium: Wait Until Element is Present

Your logic is just slightly off..The actual ...READ MORE

answered Apr 20, 2018 in Selenium by king_kenny
• 3,650 points
6,369 views