How to Automate Chrome Request Blocking Using Selenium-Webdriver for Ruby

Selenium block requests, scripts before page loaded

The solution is:

https://chrome.google.com/webstore/detail/http-request-blocker/eckpjmeijpoipmldfbckahppeonkoeko?hl=en

edit and install an extension like this. This can be a solution for request blocking.

Automate Chrome Extensions With Selenium and Ruby

To launch Chrome with the default profile on Windows:

require 'selenium-webdriver'

switches = ['user-data-dir='+ENV['LOCALAPPDATA']+'\\Google\\Chrome\\User Data']
driver = Selenium::WebDriver.for :chrome, :switches => switches

driver.navigate.to "https://www.google.co.uk"

Or to add an extension to the created profile:

require 'selenium-webdriver'

driver = Selenium::WebDriver.for :chrome,
:desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome({
'chromeOptions' => {
'extensions' => [
Base64.strict_encode64(File.open('C:\\App\\extension.crx', 'rb').read)
]
}
})

driver.navigate.to "https://www.google.co.uk"

Is there a method of automating the process of downloading the latest Chrome Driver for a Selenium project?

please find below answer :

use below command to install webdriver manager

pip install webdriver_manager

**Use with Chrome:**

from webdriver_manager.chrome import ChromeDriverManager

webdriver.Chrome(ChromeDriverManager().install())

for more details please find below link::
https://github.com/SergeyPirogov/webdriver_manager



Related Topics



Leave a reply



Submit