我想运行一些与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和export 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
chromedriver-helper
gem于2019年3月31日被弃用,推荐使用webdrivers
gem - 请参阅弃用通知,因此现在应该使用gem 'webdrivers'
。 - Michael Evans