【发布时间】:2019-07-07 22:40:37
【问题描述】:
我正在尝试让 Selenium 使用 Chrome(通过 gem 'chromedriver-helper'),以便我可以使用 capybara。
但是,我一直在 irb 中遇到此错误 - Selenium::WebDriver::Error::WebDriverError: 无法找到 Mozilla geckodriver。请从https://github.com/mozilla/geckodriver/releases 下载服务器并将其放置在您的路径中的某个位置。更多信息请访问https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver。
我知道 Selenium 默认使用 Firefox 和 geckodriver,但是我的 iMac 不再获得 MacOS 更新,因此 brew 不会下载 geckodriver。 所以,我正在使用 chromedriver。
以下是我在 irb 中输入的内容。
2.3.3 :001 > require 'capybara/dsl'
=> true
2.3.3 :002 > require 'selenium-webdriver'
=> true
2.3.3 :003 > include Capybara::DSL
including Capybara::DSL in the global scope is not recommended!
=> Object
2.3.3 :004 > Capybara.default_driver = :selenium
=> :selenium
2.3.3 :005 > driver = Selenium::WebDriver.for:chrome
=> #<Selenium::WebDriver::Chrome::Driver:0x3f7ff1cdc18a3184 browser=:chrome>
2.3.3 :006 > visit 'http://capybaraworkout.herokuapp.com'
Selenium::WebDriver::Error::WebDriverError: Unable to find Mozilla geckodriver. Please download the server from https://github.com/mozilla/geckodriver/releases and place it somewhere on your PATH. More info at https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver.
我认为下面的 sn-p 告诉 Selenium 使用 Chrome,而不是 Firefox!
driver = Selenium::WebDriver.for:chrome
我期待 - 访问'http://capybaraworkout.herokuapp.com' 带我到 chrome 中的 URL(因为“访问”是一种水豚方法) 我知道 - driver.get 'http://capybaraworkout.herokuapp.com' 会将我带到 URL,但是当我使用另一种水豚方法时 - click_link '开始锻炼!'我得到同样的错误(Selenium::WebDriver::Error::WebDriverError: Unable to find Mozilla geckodriver。请从https://github.com/mozilla/geckodriver/releases 下载服务器并将其放置在您的PATH 中的某个位置。更多信息请参见https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver。)
我需要做什么才能让 Capybara 通过 Selenium 使用 Chrome?
【问题讨论】:
标签: ruby selenium-webdriver selenium-chromedriver capybara