0

我有一个 Rails 3.2 应用程序。我正在尝试设置黄瓜测试以使用 Google chrome 运行。我已经添加了相同的配置:

Capybara.register_driver :selenium do |app|
  Capybara::Selenium::Driver.new(app, :browser => :chrome)
end

另外,我已经在 /usr/bin/ 中安装了 chromedriver 及其二进制文件:

➜  ~  ls -lah /usr/bin | grep chrome
-rwxrwxrwx  1 root   root     18M May 20 15:42 chromedriver
lrwxrwxrwx  1 root   root      32 Apr  6 10:19 google-chrome -> /opt/google/chrome/google-chrome

当我尝试运行一个仅打开 google.com 并搜索某些内容的简单功能时,我收到以下错误:

unexpected response, code=404, content-type=""
      unknown command: session/url (Selenium::WebDriver::Error::WebDriverError)
      ./features/step_definitions/google_steps.rb:2:in `/^I am on the google page$/'
      features/google.feature:3:in `Given I am on the google page'

其余的跟踪:

unexpected response, code=404, content-type=""
      unknown command: session/url (Selenium::WebDriver::Error::WebDriverError)
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/remote/http/common.rb:66:in `create_response'
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/remote/http/default.rb:66:in `request'
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/remote/bridge.rb:619:in `raw_execute'
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/remote/bridge.rb:597:in `execute'
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/remote/bridge.rb:103:in `get'
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/common/navigation.rb:14:in `to'
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/capybara-2.1.0/lib/capybara/selenium/driver.rb:90:in `reset!'
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/capybara-2.1.0/lib/capybara/session.rb:77:in `reset!'
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/capybara-2.1.0/lib/capybara.rb:245:in `block in reset_sessions!'
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/capybara-2.1.0/lib/capybara.rb:245:in `each'
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/capybara-2.1.0/lib/capybara.rb:245:in `reset_sessions!'
      /home/arkiver/.rvm/gems/ruby-1.9.3-p392@tests/gems/capybara-2.1.0/lib/capybara/cucumber.rb:10:in `After'

需要帮助弄清楚我在这里缺少什么。

4

2 回答 2

0

我解决了这个问题。我(不小心?)使用了错误的驱动程序版本:

https://code.google.com/p/chromedriver/downloads/list,我下载了这个版本:

" chromedriver_linux64_26.0.1383.0.zip ChromeDriver server for linux64 "

而不是我之前选择的:

《 chromedriver2_linux64_0.8.zip版ChromeDriver2 r195627 Release》

那解决了它。

于 2013-05-20T13:24:56.103 回答
0

我有同样的问题。就我而言,我有最新的驱动程序,但我还需要将我正在使用的 selenium gem 更新到最新版本。

于 2013-08-17T20:48:33.337 回答