黄瓜;硒的webdriver - 如何使用谷歌浏览器作为测试的浏览器,而不是Firefox的
有关我的Rails应用程序3.1黄瓜情况下,我用了@javascript标记,因此硒被激活。
我收到以下错误:
For a Cucumber scenario on my Rails 3.1 app, I used the @javascript tag, so Selenium is activated. I get the following error:
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)
如果可能的话,我想使用谷歌浏览器浏览器 - 火狐没有(我还没有安装)。这可能吗?可以做些什么?
If possible, I'd like to use Google Chrome as the browser - not Firefox (which I haven't installed). Is this possible? What could be done?
其实,不应该黄瓜/硒检测浏览器并使用它吗?
In fact, shouldn't Cucumber/Selenium detect a browser and use it?
==== ====编辑
====EDIT====
后加入
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
...到功能/支持/ env.rb,
现在我得到这个错误:
...to features/support/env.rb, I now get this error:
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'
我从here,我尝试了把chromedriver可执行文件在/ usr / bin中,但我仍然得到上述错误。
I've downloaded from here, and I've tried putting the chromedriver executable in /usr/bin, but I still get the above error.
====编辑2 ====
====EDIT 2====
往前一步并运行后命令搭配chmod + X的/ usr /斌/ chromedriver,如下的建议,我现在正在运行后,黄瓜得到一个新的错误:
After going one step further and running "sudo chmod +x /usr/bin/chromedriver" as suggested below, I now get a new error after running 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)
帮助AP preciated!越来越近...
Help appreciated! Getting closer...
有关水豚,将它添加到的 env.rb 的
For capybara, add this to env.rb
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
下载 Chrome的驱动程序的可执行文件以及它你的路径,例如复制的/ usr / bin中/ 的并使其可执行
Download the Chrome driver executable and copy it in you path, e.g. /usr/bin/ and make it executable
$ sudo chmod +x /usr/bin/chromedriver