7

I had an app using chromedriver on a Linux machine, and I switched the app over to a Windows 10 machine. Now suddenly it's telling me that it can't find the chromedriver file.

Here's error:

Selenium::WebDriver::Error::WebDriverError in Static#home
Showing C:/Users/User/Documents/test_app/app/views/static/home.html.erb where line #4 raised:

    Unable to find chromedriver. 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.

I placed the chromedriver file in the same place it was on my Linux machine, right in the main folder of the app. In this case the path is C:\Users\User\Document\test_app. Does Windows interpret paths differently than Linux?

The chromedriver is the latest release. It's titled "chromedriver_win32.zip". The "win" means Windows. Could the "32" mean it's for a 32-bit system? My machine is 64-bit.

Joe Morano
  • 1,715
  • 10
  • 50
  • 114
  • The `PATH` from the exception refers to the environment variable. Your issue is probably because the current directory is not `C:\Users\User\Document\test_app`. – Florent B. Oct 24 '16 at 18:57
  • @FlorentB. I'm definitely running my rails server in that exact directory. My pages that don't use chromedriver all work. – Joe Morano Oct 24 '16 at 19:09

3 Answers3

4

If you put the chromedriver.exe in the folder Chromedriver_win32.zip which is in the same folder as your script, you can set the driver_path to that file. See code below:

require "selenium-webdriver"

Selenium::WebDriver::Chrome.driver_path = File.join(File.absolute_path('./', "Chromedriver_win32.zip/chromedriver.exe"))    
driver = Selenium::WebDriver.for :chrome
driver.get "https://www.google.com.sg/"
Buaban
  • 5,029
  • 1
  • 17
  • 33
3

I don't have any knowledge on ruby or ruby-on-rails. please find the equivalent in java or python in Windows OS.

Two ways:

  1. you can keep Chrome driver in a place where it is added to PATH variable (environment variables in Windows 10)
  2. Programmatically set the path to the executable chromedriver.exe

For Java:

 System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");

For Python : (we keep chromedriver.exe in C:\Python27\Scripts location. this location is already added to PATH variable when python (Activestate) is installed. in case, chromedriver.exe is not in one of the PATH locations, you can specify as follows)

driver = webdriver.Chrome('/path/to/chromedriver')  # Optional argument, if not specified will search path.

For Ruby:

Add the ruby installation path to Windows PATH environment variable and keep chromedriver.exe in that location. (Windows searches for binaries in the locations specified in PATH variable.)

For more info on setting ruby installation location to PATH https://stackoverflow.com/a/26947536

References:

  1. https://sites.google.com/a/chromium.org/chromedriver/getting-started
Community
  • 1
  • 1
Naveen Kumar R B
  • 6,248
  • 5
  • 32
  • 65
1

I would put this in as a comment, but, since I'm relatively new, I am forced to put it in as an answer, which it might well be...

Pardon me if I'm asking the obvious, but, did you try "unzipping" the file and putting the ".exe" file into that directory? The file you mentioned (you said.. titled "chromedriver_win32.zip") is not an executable file in Windows. The file you should be looking for is chromedriver.exe.