+2 votes
1 view
in Devops and Agile by (20k points)

Can anyone let me how can I make selenium wait until the time the page loads completely? I want something generic, I know I can configure WebDriverWait and call something like 'find' to make it wait but I don't go that far. I just need to test that the page loads successfully and move on to next page to test.

I found something in .net but couldn't make it work in 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?

1 Answer

+1 vote
by (28.4k points)
edited by

The following command will wait up to 10 seconds for page loading. If the page loading exceeds that time it will throw the TimeoutException.

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

For more information please go through the following tutorial to get more info about selenium:

 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...