Selenium::WebDriver::Error::WebDriverError:

3

我想运行一些与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
2个回答

10
安装chromedriver-helper gem对我很有用。
添加。
gem 'chromedriver-helper'

将其添加到Gemfile中并发送给您的测试组。


1
chromedriver-helper gem于2019年3月31日被弃用,推荐使用webdrivers gem - 请参阅弃用通知,因此现在应该使用gem 'webdrivers' - Michael Evans

3
我不了解capybera,但针对这个错误,您可以检查以下两点:
1. 确保您提供了包括文件名在内的完整路径chromedriver.exe(如果您在linux中,请使用chromedriver)。 如果在Windows中,您需要指定 .exe。
2. 如果您正在使用remotewebdriver,而不是更新path变量,您可以尝试在启动selenium服务器时提供此路径。例如:
java -jar selenium.jar -Dwebdriver.chrome.driver=fullpathtoexefileincludingfilename

谢谢,你的答案帮助我找到了正确的方向。这解决了问题:https://dev59.com/LmLVa4cB1Zd3GeqPuj8X#10010381 - Ectac

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接