R
R
Rome2012-08-04 03:47:57
Python
Rome, 2012-08-04 03:47:57

Selenium WebDriver how to stop page from loading?

I am using Selenium2 WebDriver, Python language.
The problem is the following. There are sites with eternal page loading, that is, some js elements on the page that cannot be loaded in any way.
For example:

driver = webdriver.Firefox()
driver.get("http://science.compulenta.ru/698674/")

After Firefox has opened the page, loaded the content, something continues to load. driver.get waits for the download to complete and does nothing further. If you yourself click on stop loading with the mouse, then the code will continue to be executed.

Question. How to limit page load time? That is, give only half a minute and then the stop is automatically pressed.

Spent several hours looking for solutions. There is a lot on the Internet how to do this in java, but I could not do it in python.

Thank you all in advance for your replies.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
egorinsk, 2012-08-04
@egorinsk

Have you tried to write to the authors of Selenium about this flaw?

A
alexkuzpro, 2014-12-08
@alexkuzpro

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("webdriver.load.strategy", "unstable");
WebDriver driver = new FirefoxDriver(profile);
driver.manage().timeouts().pageLoadTimeout(30000, TimeUnit.MILLISECONDS);
driver.get(" toster.ru ");
When using this loading strategy, the driver will not wait for the page to fully load.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question