Selenium 一直在尝试寻找 geckodriver,即使我认为我已经在使用 Ruby 2.3.3 时使用 Chromedriver 对其进行了设置
Selenium keep trying to find geckodriver, even when I think I've set it up with Chromedriver while using Ruby 2.3.3
我正在尝试让 Selenium 使用 Chrome(通过 gem 'chromedriver-helper')以便我可以使用水豚。
但是,我在 irb 中一直遇到这个错误 -
Selenium::WebDriver::Error::WebDriverError: 无法找到 Mozilla geckodriver。请从 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 下载服务器。
我知道 Selenium 默认使用 Firefox 和 geckodriver,但是我的 iMac 不再获取 MacOS 更新,所以 brew 不会下载 geckodriver。
所以,我正在使用 chrome 驱动程序。
以下是我在 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.
我认为下面的代码片段告诉 Selenium 使用 Chrome,而不是 Firefox!!
driver = Selenium::WebDriver.for:chrome
我期待 -
访问“http://capybaraworkout.herokuapp.com”
带我去 chrome 中的 URL (因为 'visit' 是水豚方法)
我知道 - driver.get 'http://capybaraworkout.herokuapp.com' 会带我到 URL,但是当我使用另一种水豚方法时 - click_link 'Start Workout!' 我得到相同的结果错误(Selenium::WebDriver::Error::WebDriverError:无法找到 Mozilla geckodriver。请从 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 下载服务器。)
我需要做什么,才能让 Capybara 通过 Selenium 使用 Chrome?
您需要注册一个具有特定配置的驱动程序来告诉 Capybara 使用不同的浏览器 - https://github.com/teamcapybara/capybara#configuring-and-adding-drivers. However, if all you want is Selenium using Chrome with a default setup then Capybara already has a driver registered for you - https://github.com/teamcapybara/capybara#selenium
Capybara.default_driver = :selenium_chrome
这将要求您安装 chromedriver(chromedriver-helper gem 可以安装,尽管我建议使用 webdrivers
gem)。如果您不想使用 selenium/chromedriver,那么有几个更新的选项可以直接与 Chrome 对话,其中之一是 appartion
驱动程序 - https://github.com/twalpole/apparition
我正在尝试让 Selenium 使用 Chrome(通过 gem 'chromedriver-helper')以便我可以使用水豚。
但是,我在 irb 中一直遇到这个错误 - Selenium::WebDriver::Error::WebDriverError: 无法找到 Mozilla geckodriver。请从 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 下载服务器。
我知道 Selenium 默认使用 Firefox 和 geckodriver,但是我的 iMac 不再获取 MacOS 更新,所以 brew 不会下载 geckodriver。 所以,我正在使用 chrome 驱动程序。
以下是我在 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.
我认为下面的代码片段告诉 Selenium 使用 Chrome,而不是 Firefox!!
driver = Selenium::WebDriver.for:chrome
我期待 - 访问“http://capybaraworkout.herokuapp.com” 带我去 chrome 中的 URL (因为 'visit' 是水豚方法) 我知道 - driver.get 'http://capybaraworkout.herokuapp.com' 会带我到 URL,但是当我使用另一种水豚方法时 - click_link 'Start Workout!' 我得到相同的结果错误(Selenium::WebDriver::Error::WebDriverError:无法找到 Mozilla geckodriver。请从 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 下载服务器。)
我需要做什么,才能让 Capybara 通过 Selenium 使用 Chrome?
您需要注册一个具有特定配置的驱动程序来告诉 Capybara 使用不同的浏览器 - https://github.com/teamcapybara/capybara#configuring-and-adding-drivers. However, if all you want is Selenium using Chrome with a default setup then Capybara already has a driver registered for you - https://github.com/teamcapybara/capybara#selenium
Capybara.default_driver = :selenium_chrome
这将要求您安装 chromedriver(chromedriver-helper gem 可以安装,尽管我建议使用 webdrivers
gem)。如果您不想使用 selenium/chromedriver,那么有几个更新的选项可以直接与 Chrome 对话,其中之一是 appartion
驱动程序 - https://github.com/twalpole/apparition