5

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!

Community
  • 1
  • 1
hardknocks
  • 155
  • 1
  • 7
  • Thank you to both Nguyen Vu Hoang and mtm. Between the two, I just added a :switch with --test-type argument and that took care of it. – hardknocks Jul 22 '14 at 13:41

5 Answers5

2

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.

Matt
  • 68,711
  • 7
  • 155
  • 158
1

I adjusted:

driver = Selenium::WebDriver.for :chrome

to read:

driver = Selenium::WebDriver.for :chrome, :switches => %w[--test-type]

...and the script ran successfully without the yellow flag. Clearly, other command-line switches could be added.

Thank you to Nguyen Vu Hoang and mtm.

hardknocks
  • 155
  • 1
  • 7
0

I donot know ruby, however my approach is set mode "test-type" to ChromeDriver capabilities

Here's my sample code in Java

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type", "start-maximized",
        "no-default-browser-check");    
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
Nguyen Vu Hoang
  • 1,570
  • 14
  • 19
0

With Capybara:

Capybara.register_driver :chrome do |app|
  Capybara::Selenium::Driver.new(app, browser: :chrome, switches: ['--test-type'])
end
Paul Pettengill
  • 4,843
  • 1
  • 29
  • 33
0

This error caused my rspec tests to fail. I think it was causing Chrome to slow down so the above fixes did remove the error messages but did not resolve my problem of my tests failing.

If you are using chromedriver-helper then this should fix the problem. Run this from the command line

chromedriver-update

This is described more in chromedriver-helper, "This might be necessary on platforms on which Chrome auto-updates, which has been known to introduce incompatibilities with older versions of chromedrive"

Once I ran this I was able to remove the fixes described elsewhere and Chrome ran with out warnings.

Community
  • 1
  • 1
haley
  • 1,573
  • 2
  • 12
  • 19