Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does chrome chrome driver support PageLoadStrategy='eager' for Selenium?

I'm trying to scrape some stuff using Selenium/headless chrome. In some pages, the driver will not move to the next step until the full page is loaded (even though the relevant elements are present).

I tried setting the pageLoadStrategy capability like so:

caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => [ "--headless" ]})
      caps['pageLoadStrategy']='eager'
self.driver||=Selenium::WebDriver.for :chrome, :desired_capabilities =>  caps

I get the following error:

Selenium::WebDriver::Error::UnknownError: unknown error: cannot parse capability: pageLoadStrategy
from unknown error: page load strategy unsupported

Is there a way to make this work with chrome?

According to this post, pageLoadStrategy is supported, but I can't get the 'eager' option to work.

Page load strategy for Chrome driver

If not, are there more tried and true ways of doing this. I've been having a lot of trouble with Chrome (it also doesn't support unexpectedAlertBehaviour)

like image 817
Gabriel Avatar asked Mar 08 '23 08:03

Gabriel


1 Answers

Chrome does not support PageLoadStrategy.EAGER. But you can try PageLoadStrategy.NONE. Sometimes you need to synchronize driver wait for some elemnts but possibility is less.

like image 87
Rohit Borse Avatar answered Apr 25 '23 18:04

Rohit Borse