2

I use Selenium to browse multiple websites and store their markup.

In order to speed things up, I have set a pageLoadTimeout to throw an exception for sites that take too long to load:

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

However, this seems not to work for websites that are constantly redirecting. As an example, take this site: https://www.pickupthevalues.com/SignUp.aspx.

Is there a way to get a timeout for such sites? I do not care about the content, I just want to be able to return from my driver.get(url) statement.

mario.schlipf
  • 1,257
  • 2
  • 13
  • 29
  • if you are just storing markup, then you should use something faster, like simple `cURL`. unless of course you are actually interacting with elements on the page. then selenium is fine – ddavison Oct 30 '15 at 19:22
  • The reason I use Selenium is because I want the markup how it is presented to the user. This may be significantly different than just using cURL due to JS/AJAX – mario.schlipf Oct 30 '15 at 21:32

1 Answers1

0

you can wait untill js return page complete status.

private WebDriverWait wait;

try
{
   wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));                
   wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete"));
}
catch(Exception ex)
{}
Leon Barkan
  • 2,676
  • 2
  • 19
  • 43