Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsupported command-line flag: --ignore-certificate-errors (in Ruby)

Using Ruby 2.0.0 p481 in RubyMine and chromedriver 2.10

When Chrome starts it displays a message in a yellow popup bar: "You are using an unsupported command-line flag: --ignore-certificate-errors. Stability and security will suffer." This simple example reproduces the problem.

require "selenium-webdriver" 
driver = Selenium::WebDriver.for :chrome 
driver.navigate.to login_url

This question has been answered for Java and Python. I have looked everywhere for a Ruby analog. Does anyone have a suggestion or know how to translate the Python answer (Unsupported command-line flag: --ignore-certificate-errors) to Ruby? Thank you!

like image 214
hardknocks Avatar asked Oct 21 '22 04:10

hardknocks


1 Answers

The Ruby selenium-webdriver API doesn't expose a separate Chrome options object like Java/Python but you can set the options via "Capabilities".

The Capabilities web page provides a Ruby example and the table of recognized capabilities that you can inject. Plugging those together with excludeSwitches:

caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"excludeSwitches" => [ "--ignore-certificate-errors" ]})
driver = Selenium::WebDriver.for :chrome, desired_capabilities: caps

Take a look at Watir too, it's a front end for WebDriver.
Their examples show how you can send a :switches array which is passed straight through to the web driver so you can do the same. That makes adding other switches a bit easier rather than going through capabilities.

There is a chromedriver issue on the topic as well. There are posts detailing that you can add a --test-type argument to work around the certificate issue and ruby code examples like above.

like image 159
Matt Avatar answered Oct 28 '22 15:10

Matt