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.
Try using explicit wait . Visit this link. It might be helpful
Try this code as well:
I hope your problem will be resolved using above code
In C#, since PageLoadStrategy.Eager doesn't seem to work for Chrome, I just wrote it myself with a WebDriverWait. Set the PageLoadStrategy to none and then doing this will basically override it:
You just add in your chrome driver as a parameter and the TimeSpan is set to a max of 20 seconds in my case. So it will wait a max of 20 seconds for the page to be interactive or complete
From the Webdriver specs:
When
Page Loading
takes too much time and you need to stop downloading additional subresources (images, css, js etc) you can change thepageLoadStrategy
through thewebdriver
.As of this writing,
pageLoadStrategy
supports the following values :normal
This stategy causes Selenium to wait for the full page loading (html content and subresources downloaded and parsed).
eager
This stategy causes Selenium to wait for the DOMContentLoaded event (html content downloaded and parsed only).
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 thenormal
pageLoadStrategy
.Here is the code block to configure
pageLoadStrategy()
through both an instance of DesiredCapabilities Class and ChromeOptions Class as follows : :Using DesiredCapabilities Class :
Using ChromeOptions Class :
References: