【问题标题】:Unsupported command-line flag: --ignore-certificate-errors (in Ruby)不支持的命令行标志:--ignore-certificate-errors(在 Ruby 中)
【发布时间】:2014-09-12 12:36:54
【问题描述】:

在 RubyMine 和 chromedriver 2.10 中使用 Ruby 2.0.0 p481

Chrome 启动时会在黄色弹出栏中显示一条消息:“您正在使用不受支持的命令行标志:--ignore-certificate-errors。稳定性和安全性将受到影响。”这个简单的例子重现了这个问题。

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

已针对 Java 和 Python 回答了此问题。我到处寻找 Ruby 模拟。有没有人有建议或知道如何将 Python 答案 (Unsupported command-line flag: --ignore-certificate-errors) 翻译成 Ruby?谢谢!

【问题讨论】:

  • 感谢 Nguyen Vu Hoang 和 mtm。在这两者之间,我只是添加了一个带有 --test-type 参数的 :switch 并处理了它。

标签: ruby selenium selenium-chromedriver


【解决方案1】:

Ruby selenium-webdriver API 不会像 Java/Python 那样公开单独的 Chrome 选项对象,但您可以通过 "Capabilities" 设置选项。

Capabilities web page 提供了一个 Ruby 示例和您可以注入的 table of recognized capabilities。将它们与excludeSwitches 一起插入:

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

也可以看看Watir,它是 WebDriver 的前端。
他们的examples 展示了如何发送:switches array,该:switches array 会直接传递到Web 驱动程序,这样您就可以执行相同的操作。这使得添加其他开关比通过功能更容易一些。

还有一个关于该主题的chromedriver 问题。有帖子详细说明您可以添加 --test-type 参数来解决证书问题和 ruby code examples 像上面一样。

【讨论】:

    【解决方案2】:

    我调整了:

    driver = Selenium::WebDriver.for :chrome
    

    阅读:

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

    ...脚本在没有黄旗的情况下成功运行。显然,可以添加其他命令行开关。

    感谢 Nguyen Vu Hoang 和 mtm。

    【讨论】:

      【解决方案3】:

      我不知道 ruby​​,但是我的方法是将模式“测试类型”设置为 ChromeDriver 功能

      这是我的 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);
      

      【讨论】:

        【解决方案4】:

        Capybara:

        Capybara.register_driver :chrome do |app|
          Capybara::Selenium::Driver.new(app, browser: :chrome, switches: ['--test-type'])
        end
        

        【讨论】:

          【解决方案5】:

          这个错误导致我的 rspec 测试失败。我认为这导致 Chrome 速度变慢,因此上述修复确实删除了错误消息,但没有解决我的测试失败的问题。

          如果您使用的是chromedriver-helper,那么这应该可以解决问题。从命令行运行它

          chromedriver-update
          

          这在chromedriver-helper 中有更多描述,“这在 Chrome 自动更新的平台上可能是必需的,已知这会引入与旧版本 chromedrive 的不兼容性”

          运行此程序后,我能够删除其他地方描述的修复程序,Chrome 运行时没有警告。

          【讨论】:

            猜你喜欢
            • 2014-08-01
            • 1970-01-01
            • 2014-07-21
            • 1970-01-01
            • 1970-01-01
            • 2018-08-11
            • 2019-10-20
            • 2017-06-27
            • 2017-09-14
            相关资源
            最近更新 更多