For Selenium 4
& Chrome <75
users
options = {
args: ['disable-infobars', 'disable-gpu', 'privileged', 'ignore-certificate-errors', 'no-default-browser-check'],
w3c: true,
mobileEmulation: {},
prefs: {
:protocol_handler => {
:excluded_schemes => {
tel: false,
}
}
},
extensions: [ Base64.strict_encode64(File.open("../your_extension.crx", 'rb').read) ]
}
caps = Selenium::WebDriver::Chrome::Options.new(options: options)
@driver = Selenium::WebDriver.for(:chrome, options: caps)
For Selenium 3
users
Used switches to define chrome options
caps = Selenium::WebDriver::Remote::Capabilities.chrome("desiredCapabilities" => {"takesScreenshot" => true}, "chromeOptions" => {"binary" => "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"})
@driver = Selenium::WebDriver.for :chrome, desired_capabilities: caps, switches: %w[--incognito --screen-size=1200x800]
Or
driver = Selenium::WebDriver.for :chrome, switches: %w[--incognito]
RemoteWebDriver
caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => [ "disable-infobars" ]})
driver = Selenium::WebDriver.for :remote, url: 'http://localhost:4444/wd/hub', desired_capabilities: caps
Chrome switches list
https://peter.sh/experiments/chromium-command-line-switches/
autoload :Chrome, 'selenium/webdriver/chrome'
– VaporizationSelenium::WebDriver::Chrome::Options
exists but will only load it when you use it. If autoload is broken somehow then this won't work – Vaporizationgem unpack
into your directory and edit theautoload
line to berequire
instead – Vaporization