【问题标题】:How do I use Ruby gem selenium-webdriver with Chromium?如何将 Ruby gem selenium-webdriver 与 Chromium 一起使用?
【发布时间】:2016-01-05 18:18:50
【问题描述】:

我使用 Debian 8.2 “Jessie” 和 Ruby 2.1.5。

test.rb 中,我有require selenium-webdriver,但是当我运行Selenium::WebDriver.for :ChromeDriver 时出现此错误:

/var/lib/gems/2.1.0/gems/selenium-webdriver-2.48.1/lib/selenium/webdriver/common/driver.rb:72:in `for': unknown driver: :ChromeDriver (ArgumentError)

我没有 Chrome,但有 Cromium。如何让 Selenium 合作?

【问题讨论】:

  • 在 *nix 系统上没有特定的 Chromium 驱动程序。因此,您需要使用 :chrome 作为驱动程序,而不是 :ChromeDriver。试试 Selenium::WebDriver.for :chrome.
  • 我收到此错误:/var/lib/gems/2.1.0/gems/selenium-webdriver-2.48.1/lib/selenium/webdriver/chrome/service.rb:37:in executable_path': Unable to find the chromedriver executable. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. (Selenium::WebDriver::Error::WebDriverError)。我去了'chromedriver.storage.googleapis.com/index.html'并将v2.20中的chromedriver放入/usr/local/bin。仍然出现同样的错误。
  • 好的,这至少提供了更多细节。尝试使用这个 gem 来设置你的 chromedriver:github.com/flavorjones/chromedriver-helper
  • @Sam 成功了!如果您希望我标记它,您可以发布您的解决方案作为答案。

标签: ruby linux selenium debian chromium


【解决方案1】:

在 *nix 系统上没有特定的 Chromium 驱动程序。所以你需要使用:chrome作为驱动,代替:ChromeDriver,例如Selenium::WebDriver.for :chrome

此外,使用此 gem 在您的执行系统上轻松设置 chromedriver:https://github.com/flavorjones/chromedriver-helper

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-17
    • 2013-04-29
    • 2013-08-17
    • 2013-06-15
    • 2012-02-23
    相关资源
    最近更新 更多