Page load strategy for Chrome driver

0
0

I’m using Chrome browser for testing WebApp.

Sometimes pages loaded after very long time. I needed to stop downloading or limit their download time.

In FireFox I know about PAGE_LOAD_STRATEGY = "eager".

Is there something similar for chrome?

P.S.: driver.manage().timeouts().pageLoadTimeout() works, but after that any treatment to Webdriver throws TimeOutException.
I need to get the current url of the page after stopping its boot.

  • You must to post comments
0
0

From the Webdriver specs:

For commands that cause a new document to load, the point at which the command returns is determined by the session’s page loading strategy.

When Page Loading takes too much time and you need to stop downloading additional subresources (images, css, js etc) you can change the pageLoadStrategy through the webdriver.

As of this writing, pageLoadStrategy supports the following values :

  1. normal

    This stategy causes Selenium to wait for the full page loading (html content and subresources downloaded and parsed).

  2. eager

    This stategy causes Selenium to wait for the DOMContentLoaded event (html content downloaded and parsed only).

  3. none

    This strategy causes Selenium to return immediately after the initial page content is fully received (html content downloaded).

By default, when Selenium loads a page, it follows the normal pageLoadStrategy.


Here is the code block to configure the pageLoadStrategy :

    ChromeOptions options = new ChromeOptions();
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
capabilities.setCapability("pageLoadStrategy", "none");
WebDriver driver = new ChromeDriver(capabilities);
driver.navigate().to("http://www.longer_pageload_url.com");

References:

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website