TestProject Forum
Powered by leading experts in the test automation community

Navigate to url without waiting for page to load

When I navigate with driver.get() the driver seems to be waiting for the entire page to load before proceeding.

Is it possible to tell the driver to not wait for the entire page to load?
Several of the pages that I’m loading have heavy external resources that take too long to fetch.

I’m more interested in the DOM elements to be present than wait for everything to load. Some tests take double the time because of this

It is possible only in firefox while running in special mode.

You have to set preference in firefox profile beforehand:

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("webdriver.load.strategy", "unstable");
WebDriver driver = new FirefoxDriver(profile);

Then you can set a timeout:

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