Need details about Page load strategy for Chromedriver

0 votes
I'm using Chrome for testing a page. At times, the pages load after a long time. I need to find a way to stop downloading or atleast limit their download time.

I know that in FireFox, I can use PAGE_LOAD_STRATEGY = "eager". Is there anything similar for Chrome?

Even though driver.manage().timeouts().pageLoadTimeout() works, after that, any treatment to Webdriver throws TimeOutException. I want the current url of the page after stopping its boot.
May 31, 2018 in Selenium by eLiJha
• 770 points
7,663 views

1 answer to this question.

0 votes

According to WebDriver docs, when Page Loading takes lot of time, then you need to stop downloading additional subresources like (images, css, js etc) and you can modify the pageLoadStrategy through WebDriver.

As of now, pageLoadStrategy supports the following values:

normal:-
This will make Selenium wait till the entire page is loaded. (html content and subresources downloaded and parsed).

eager:-
This will make Selenium wait for DOMContentLoaded event (html content downloaded and parsed only).

none:-
This will make Selenium to return immediately after the initial page content is completely received (html content downloaded).

By default, when Selenium loads a page, it follows the normal pageLoadStrategy. You can implement it using DesiredCapabilities() with firefox or ChromeOptions() for chrome. Usage is below.

DesiredCapabilities-

System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");

        DesiredCapabilities dcap = new DesiredCapabilities();

        dcap.setCapability("pageLoadStrategy", "normal");

        FirefoxOptions opt = new FirefoxOptions();

        opt.merge(dcap);

        WebDriver driver = new FirefoxDriver(opt);

        driver.get("https://www.google.com/");

        System.out.println(driver.getTitle());

        driver.quit();

ChromeOptions-

        System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");

        FirefoxOptions opt = new FirefoxOptions();

        opt.setPageLoadStrategy(PageLoadStrategy.NORMAL);

        WebDriver driver = new FirefoxDriver(opt);

        driver.get("https://www.google.com/");

        System.out.println(driver.getTitle());

        driver.quit();
answered May 31, 2018 by king_kenny
• 3,710 points

Related Questions In Selenium

0 votes
1 answer

Wait for page to load using HtmlUnitDriver

You can create a custom ExpectedCondition public static ...READ MORE

answered May 7, 2018 in Selenium by anonymous
2,734 views
0 votes
1 answer

I need to release the memeory allocated to Selenium chromedriver.exe while for tests

The usage of the commands is incorrect. driver.close() ...READ MORE

answered May 21, 2018 in Selenium by sniffy_god
• 780 points
6,687 views
0 votes
1 answer

How do you make Selenium 2.0 wait for the page to load?

You can also check pageloaded using following ...READ MORE

answered Nov 27, 2020 in Selenium by Gitika
• 65,770 points
577 views
+1 vote
4 answers

Need to wait until page is completely loaded - Selenium WebDriver

You can try something like -  new WebDriverWait(firefoxDriver, ...READ MORE

answered Dec 21, 2019 in Selenium by Robin
64,278 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,649 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,131 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,209 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,865 views
0 votes
1 answer

Need to scroll down for locating an Element with Selenium

There are a couple of options for ...READ MORE

answered Apr 21, 2018 in Selenium by king_kenny
• 3,710 points
12,945 views
0 votes
1 answer

Selenium Alternatives: Is there a tool like Selenium for testing web pages but which does not involve coding.

I'm guessing you've tried Selenium IDE already. ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,710 points
782 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP