Set up a real timeout for loading page in Selenium WebDriver? Set up a real timeout for loading page in Selenium WebDriver? python python

Set up a real timeout for loading page in Selenium WebDriver?


You could try using the page load timeout introduced in the library. The implementation of it is not universal, but it's exposed for certain by the .NET and Java bindings, and has been implemented in and the Firefox driver now, and in the IE driver in the forthcoming 2.22. In Java, to set the page load timeout to 15 seconds, the code to set it would look like this:

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

If it's not exposed in the Python language bindings, I'm sure the maintainer would eagerly accept a patch that implemented it.


You can still speedup your script execution by waiting for presence (not waiting for visibility) of expected element for say 5-8 sec and then sending window.stop() JS Script (to stop loading further elements ) without waiting for entire page to load or catching the timeout exception for page load after 5-8 seconds then calling window.stop()

Because if the page not adopted lazy loading technique (loading only visible element and loading rest of element only after scroll) it loads each element before returning window.ready state so it will be slower if any of the element takes longer time to render.