I'm translating some Selenium RC tests to Selenium WebDriver using the python api. In Selenium WebDriver, I'm noticing that driver.get( 'http://...' )
seems to wait for the entire page to load before proceeding. Is there a way to not wait for a page to load? Some of the pages I'm requesting have a lot of external resources that can potentially take a long time to load. I'd rather wait for elements on the DOM to be present than wait for everything to load. Some of my tests seem to take twice as long in WebDriver because of this.
Yes and no. As of Selenium 2.24.1, the support for this is only in Firefox - you have to run it in a special "mode":
FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("webdriver.load.strategy", "unstable");
WebDriver driver = new FirefoxDriver(fp);
You can even set the timeout if you want to. This method fails in any browser other than Firefox and does nothing in Firefox without the unstable strategy:
driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With