在我的Rails 3.1应用程序中,为了Cucumber场景测试,我使用了@javascript标签,因此激活了Selenium。我遇到了以下错误:
Could not find Firefox binary (os=macosx). Make sure Firefox is installed or set the path manually with Selenium::WebDriver::Firefox::Binary.path= (Selenium::WebDriver::Error::WebDriverError)
如果可能的话,我想使用Google Chrome作为浏览器 - 而不是Firefox(我没有安装它)。这是否可行?有什么可以做的吗?实际上,Cucumber/Selenium难道不应该检测浏览器并使用它吗?
====编辑====
添加后
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
将...添加到features/support/env.rb之后,我现在得到了这个错误:
Unable to find the chromedriver executable. Please download the server from http://code.google.com/p/chromium/downloads/list and place it somewhere on your PATH. More info at http://code.google.com/p/selenium/wiki/ChromeDriver. (Selenium::WebDriver::Error::WebDriverError)
./features/step_definitions/web_steps.rb:45:in `/^(?:|I )am on (.+)$/'
features/update_memories.feature:11:in `Given I am on the home page'
我从这里下载了文件。我试着将可执行的chromedriver放在/usr/bin路径下,但仍然遇到上述错误。
====编辑 2====
按照下面的建议更进一步操作并运行 "sudo chmod +x /usr/bin/chromedriver" 后,运行cucumber时我现在收到一个新的错误:
@javascript
Scenario: navigate to memory update page from home page # features/update_memories.feature:11
Given I am on the home page # features/step_definitions/web_steps.rb:44
unable to connect to chromedriver http://127.0.0.1:57870 (Selenium::WebDriver::Error::WebDriverError)
./features/step_definitions/web_steps.rb:45:in `/^(?:|I )am on (.+)$/'
features/update_memories.feature:12:in `Given I am on the home page'
When I activate the edit memory switch for the memory "I played" # features/step_definitions/memories/memory_steps.rb:5
Then I should be on the edit memory page for the memory "I played" # features/step_definitions/web_steps.rb:187
PGError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
: ROLLBACK (ActiveRecord::StatementInvalid)
需要帮助!越来越接近了...
sudo mv chromedriver /usr/local/bin/chromedriver
。 - Jeff Tian