Selenium::WebDriver::Error::WebDriverError:

我怕爱的太早我们不能终老 提交于 2020-01-04 01:59:14

问题


I am trying to run some acceptance tests for javascript code. However, when I tried using Capybara with Selenium, I kept getting the following:

>> 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)>'

The code below is what is supposed to start the driver. I downloaded the appropriate file from http://code.google.com/p/chromedriver/downloads/list and I placed it in my Path by running PATH=$PATH:/directory/where/chromedriver/exists and export PATH, and made it executable but still got the error. Is there something I am missing?

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

回答1:


I don't know capybera, but for this error you can check 2 things

  1. Make sure you have given the full path including the filename to chromedriver.exe (or chromedriver if you are in linux). If in windows you need to specify the .exe also.

  2. If you are using remotewebdriver, rather than updating the path variable, you can try giving this path while you start the selenium server. Like

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




回答2:


Installing the chromedriver-helper gem worked for me.

Add

gem 'chromedriver-helper'

to your test group in the Gemfile.



来源:https://stackoverflow.com/questions/10650360/seleniumwebdrivererrorwebdrivererror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!