11

I'm trying to get Selenium tests running with Chrome. I'm using C#.

var options = new OpenQA.Selenium.Chrome.ChromeOptions();
options.BinaryLocation = @"C:\Users\Vilem\AppData\Local\Google\Chrome\Application\";

using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(options))
{
...

Seems like chromedriver.exe was found but it could find the Chrome binary. I set up the path to chrome.exe explicitly after automatic search failed. I even tried it with "chrome.exe" at the end. I always get the same result:

Could not find Chrome binary at:

C:\Users\Vilem\AppData\Local\Google\Chrome\Application


FYI: I have a question concerning 3 selenium webdrivers. I'm trying to split the question into multiple so the discussion is easier. Original: Selenium WebDriver - No driver is working for me

Cœur
  • 37,241
  • 25
  • 195
  • 267
Vilém Procházka
  • 1,060
  • 2
  • 17
  • 28
  • See this post "I get error when I try to run my test in Chrome" [link](http://stackoverflow.com/questions/10654060/selenium-webdriver-i-get-error-when-i-try-to-run-my-test-in-chrome) – Dumitru Chirutac Jul 16 '12 at 16:01
  • Thanks. The driver isn't the problem - it is found correctly. After that the driver looks for the Chrome binary but fails even though the path is set correctly. – Vilém Procházka Jul 16 '12 at 16:18

7 Answers7

3

This is a typical problem in some localized Windows XP distributions.

I describe a solution for Python because it is different, without CamelCase property BinaryLocation identifier and it is less documented. Yes, a general solution is to create a new instance of ChromeOptions, but it is possible simply to fix the bug dynamically directly by ChromeOptions by some code started first somewhere:

from selenium import webdriver
webdriver.ChromeOptions.binary_location = ur"c:\Documents and Settings\user name\Local Settings\Data aplikací\Google\Chrome\Application\chrome.exe"

and leave all other code unchanged:

from selenium import webdriver
browser = webdriver.Chrome()

It is important to use ur"..." unicode raw string literal in Python (not byte string, if the path contains international characters) and not normal u"..." if the the complete path is hardcoded and the username starts with some character special after \ like \n \r \t.

hynekcer
  • 14,942
  • 6
  • 61
  • 99
0

I encountered the same issue for the php web driver.

Please install the chrome to the default directory, the chrome installations would automatically install the app to the default folder:

%HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe

Please check this wiki page for more information. http://code.google.com/p/selenium/wiki/ChromeDriver

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
dalong
  • 1
  • 3
    Welcome to Stack Overflow! Please do not use signatures/taglines in your posts. Your user box counts as your signature, and you can use your profile to post any information about yourself you like. [FAQ on signatures/taglines](http://stackoverflow.com/faq#signatures) – Andrew Barber Dec 19 '12 at 11:15
  • The problem is that such default directory `...\Application Data\...` doesn't exist on some localized Windows XP distributions because "Application Data" can be translated from English to some language. On Windows Vista and 7 it's easy. – hynekcer Jul 14 '13 at 00:04
0

Isn't the problem that you're missing the chrome.exe at the end of the path?

In other words, the path should include the executable, rather than just being the folder in which the executable is located.

teo van kot
  • 12,350
  • 10
  • 38
  • 70
  • It might not be the case. After quick look at this site: https://sites.google.com/a/chromium.org/chromedriver/capabilities it looks like only on MacOS you have to provide address to actual binary rather than the location. – PiotrWolkowski Feb 06 '15 at 00:41
0

In the path you have given for Chrome binary please specify the chrome.exe as well. It will work!

Gustavo Morales
  • 2,614
  • 9
  • 29
  • 37
k.s. Karthik
  • 731
  • 6
  • 16
0

enter image description here

  1. I reinstalled chrome and made sure it exists in the given folder.
  2. Made sure the selenium project is in the repos and not on desktop
  3. Updated all the drivers using Manage Nuget Packages
Darlan Dieterich
  • 2,369
  • 1
  • 27
  • 37
Nithya
  • 17
  • 2
0

you should have installed chrome in your machine

and your chromedriver.exe version should accordingly to chrome download form

https://chromedriver.chromium.org/downloads

and given new chromedriver.exe path to your script..

This works well for me

Hassan Saeed
  • 6,326
  • 1
  • 39
  • 37
-2

Download "chromedriver_win_22_0_1203_0b.zip" extract it and set the path as below: (I have set my path)

options.BinaryLocation = @"F:\\Software Download_Ripon\\WebDriver\\chromedriver_win_22_0_1203_0b\\chromedriver.exe";

The above should work well

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
  • 1
    BinaryLocation is to indicate chrome.exe, not chromedriver.exe https://seleniumhq.github.io/selenium/docs/api/dotnet/html/P_OpenQA_Selenium_Chrome_ChromeOptions_BinaryLocation.htm – dchang Dec 07 '18 at 16:44