Igor Varavko
Igor Varavko

Reputation: 13

Remote WebDriver ignore certificate errors for Chrome

How ignore sertificate with Remote WebDriver for Chrome? I try run this code:

#encoding: utf-8
require 'selenium-webdriver'
include Selenium

capabilities = WebDriver::Remote::Capabilities.chrome(:native_events => true)
driver = WebDriver.for(:remote,
                       :desired_capabilities => capabilities,
                       :url => "http://192.168.1.44:4444/wd/hub",
                       :switches => %w[--ignore-certificate-errors]
                       )
driver.navigate.to "https://trunk.plus1.oemtest.ru/"
puts driver.title
driver.close

And get an error message:

home/igor/.rvm/gems/ruby-1.9.2-p290@selenium/gems/selenium-webdriver-2.12.0/lib/selenium/webdriver/remote/bridge.rb:51:in `initialize': unknown option: {:switches=>["--ignore-certificate-errors"]} (ArgumentError)

Upvotes: 1

Views: 3345

Answers (3)

drewish
drewish

Reputation: 9380

It seems like now the correct way of requesting insecure certs is setting accept_insecure_certs = true on the Selenium::WebDriver::Remote::Capabilities instance.

Upvotes: 0

Vitaliy Grigoruk
Vitaliy Grigoruk

Reputation: 619

The approach described above is not supported by latest chromedriver anymore. According to this doc chromeOptions should be used instead:

caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => [ "--ignore-certificate-errors" ]})
driver = Selenium::WebDriver.for :remote, url: 'http://localhost:4444/wd/hub', desired_capabilities: caps

Upvotes: 2

jarib
jarib

Reputation: 6058

This should do the trick:

caps = Selenium::WebDriver::Remote::Capabilities.chrome
caps['chrome.switches'] = %w[--ignore-certificate-errors]

driver = Selenium::WebDriver.for(:remote, :desired_capabilities => caps)

Upvotes: 1

Related Questions