【问题标题】:Selenium::WebDriver::Error::WebDriverError:Selenium::WebDriver::Error::WebDriverError:
【发布时间】:2012-05-25 21:27:24
【问题描述】:

我正在尝试对 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 将其放置在我的路径中,并使其可执行但仍然出现错误。有什么我遗漏的吗?

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

【问题讨论】:

    标签: selenium capybara


    【解决方案1】:

    安装 chromedriver-helper gem 对我有用。

    添加

    gem 'chromedriver-helper'
    

    到 Gemfile 中的测试组。

    【讨论】:

    • chromedriver-helper gem 已于 2019 年 3 月 31 日弃用,取而代之的是 webdrivers gem - 请参阅 deprecation notice,所以现在应该是 gem 'webdrivers'
    【解决方案2】:

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

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

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

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-31
    • 2021-12-27
    相关资源
    最近更新 更多