硒:: webdriver的::错误:: WebDriverError:

时间:2012-05-18 09:50:22

标签: selenium capybara

我正在尝试对javascript代码运行一些验收测试。然而,当我尝试将Capybara与Selenium一起使用时,我不断得到以下内容:

>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:1234, CTRL+C to stop
FF>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:1234, CTRL+C to stop
F

Failures:

  1) end to end acceptance test shows that x wins when it does
     Failure/Error: @application.start
     Selenium::WebDriver::Error::WebDriverError:
       Unable to find the chromedriver executable. Please download the server from http://code.google.com/p/chromedriver/downloads/list and place it somewhere on your PATH. More info at http://code.google.com/p/selenium/wiki/ChromeDriver.>> Thin web server (v1.3.1 codename Triple Espresso)
     # ./spec/acceptance/application_driver.rb:24:in `start'
     # ./spec/acceptance/end_to_end.rb:6:in `block (2 levels) in <top (required)>'

下面的代码是启动驱动程序的原因。我从http://code.google.com/p/chromedriver/downloads/list下载了相应的文件,然后通过运行PATH = $ PATH:/ directory / where / chromedriver / exists并导出PATH将其放入我的Path中,并使其可执行但仍然出错。有什么我想念的吗?

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

Capybara.default_driver = :chrome

class TicTacToeApplicationDriver
  include Capybara::DSL
  include Capybara::RSpecMatchers

  APPLICATION_PORT = 1234

  def initialize
    @application_server = ApplicationServer.new
  end

  def start
    @application_server.start
    visit "http://localhost:#{APPLICATION_PORT}/index.html"
  end

2 个答案:

答案 0 :(得分:9)

安装chromedriver-helper gem对我有用。

添加

gem 'chromedriver-helper'

到Gemfile中的测试组。

答案 1 :(得分:3)

我不知道capybera,但是对于这个错误你可以检查2件事

  1. 确保您已将包含文件名的完整路径提供给chromedriver.exe(如果您使用的是linux,则为chromedriver)。如果在Windows中你还需要指定.exe。

  2. 如果您使用的是remotewebdriver,而不是更新路径变量,则可以在启动selenium服务器时尝试提供此路径。喜欢

  3.   

    java -jar selenium.jar   -Dwebdriver.chrome.driver = fullpathtoexefileincludingfilename