Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App running on Windows 10 machine can't find file

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.

like image 544
Joe Morano Avatar asked Oct 24 '16 18:10

Joe Morano


People also ask

How do you fix the system can not find the file specified?

Run CHKDSK Command to Fix "System Cannot Find File Specified" Device. Right-click the Start button, type cmd in the Search, and select Command Prompt (Admin). Type chkdsk x: /f /r (x represents your target drive) into the Command Prompt window and press Enter Wait while chkdsk tries to repair the corrupted file systems ...

Where are the files for an app on Windows 10?

Viewing the location of programs and apps downloaded from the Microsoft Store. Programs and apps downloaded from the Microsoft Store are installed in the following path by default: C:/Program Files/WindowsApps (Hidden items). To check hidden items, open This PC, click View and select Hidden items.

Why is a file not showing up?

The most possible reason is your files are hidden. Other factors might be some malware or virus attacking your disk and hiding or even deleting your files so that you won't see them in the folder. Some users also report that problems with compression tools can also cause your files to not be displayed.


2 Answers

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/"
like image 190
Buaban Avatar answered Oct 02 '22 18:10

Buaban


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
like image 30
Naveen Kumar R B Avatar answered Oct 02 '22 18:10

Naveen Kumar R B