2012-05-18 93 views
1

我试图运行JavaScript代码的一些验收测试。然而,当我尝试使用水豚用硒,我一直得到以下几点:硒:: webdriver的::错误:: WebDriverError:

>> 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:/目录/何/ chromedriver /存在和导出路径,并使其可执行,但仍然得到了错误。有什么我失踪?

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

我不知道capybera,但对于这个错误,您可以检查两件事情

  1. 确保你给的完整路径,包括文件名chromedriver.exe(或chromedriver如果您在Linux中)。如果在Windows中,您还需要指定.exe。

  2. 如果使用remotewebdriver,而不是更新的路径变量,可以尝试同时启动硒服务器给这个路径。像

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

+0

谢谢,你的回答帮我指出了正确的方向。这解决了这个问题: http://stackoverflow.com/a/10010381/1089462 – Ectac

8

安装chromedriver辅助宝石为我工作。

添加

gem 'chromedriver-helper' 

在Gemfile中测试组。