Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to set timeout for page load in Selenium test?

I have a problem, when sometimes test execution freezes on page load (application doesn't load new page, test hangs up), so test needs to be killed manually - this wouldn't be a problem if I would run only one test on nightly bases.

As I understand driver.manage().timeouts().pageLoadTimeout() only works on driver.get(URL) method - it doesn't work when Selenium clicks buttons and links during test execution. Is this correct? How can I manage time of wait for every page load?

share|improve this question
Does this old question help ?… – Phil Kirkham Jan 11 '13 at 12:50
Phil, it doesnt – domakas Jan 11 '13 at 14:01

You're correct that Click() will not wait for a page load, so the page load timeout does not apply. I follow clicks with a wait for some element that I know will be on the page that is loading. You can setup an implicit timeout


and then simply try to find the appropriate element


// implicit timeout
var element = driver.FindElement(By.XPath("//div[contains(@class, 'alert-error')] | //ul[id('menu')]"));

or use an explicit timeout/wait. Note that the implicit timeout still affects this code, so any explicit timeouts should be longer than the implicit setting otherwise they won't really do anything.


// explicit timeout
var wait = new WebDriverWait(driver, TimeSpan.FromMinutes(5));
var element = wait.Until(driver => driver.FindElement(By.XPath("//div[contains(@class, 'alert-error')] | //ul[id('menu')]")));
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.