Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Path to ChromeDriver for Cucumber running on Jenkins server in Ruby?

I am using Cucumber with Capybara to run automation test in Jenkins server. Everything works fine with Firefox. However, I got problem with setup Google Chrome and ChromeDriver. I have installed Google Chrome and ChromeDriver (moved chromedriver to usr/bin/chromedriver) but when the test runs, it notifies an error:

"Unable to find the chromedriver executable. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver." 

Below is my setup in env.rb for Chrome driver:

  Capybara.register_driver :chrome do |app|
    Capybara::Selenium::Driver.new(app, :browser => :chrome, :switches =>
      %w[--ignore-certificate-errors --disable-popup-blocking])
  end

How can I set path to ChromeDriver when register_driver? Have anyone experienced this issue before? Many thanks.

like image 662
Huy Do Avatar asked Jan 05 '16 10:01

Huy Do


People also ask

How do I put the ChromeDriver in the path?

Go to the terminal and type the command: sudo nano /etc/paths. Enter the password. At the bottom of the file, add the path of your ChromeDriver. Type Y to save.

Where should I place my ChromeDriver?

Now we need to move ChromeDriver somewhere that Python and Selenium will be able to find it (a.k.a. in your PATH ). The easiest place to put it is in C:\Windows . So move it there!

What is default location ChromeDriver?

Default location on Windows is: C:\Program Files\(select the folder you want to put your file)\chromedriver.exe. In your Selenium code, paste the driver path correctly, for example: System.setProperty("webdriver.chrome.driver", "C:\\Program Files\\Java\\chromedriver.exe");


1 Answers

For selenium 3.x this Selenium::WebDriver::Chrome.driver_path = <path to chromedriver> is deprecated. Now you have to put chrome_driver path in declaration of driver:

Capybara::Selenium::Driver.new(app, :browser => :chrome, :driver_path => <path to chromedriver>)

like image 148
Juanma Jurado Avatar answered Sep 18 '22 11:09

Juanma Jurado