Selenium WebDriver - Could not find Chrome binary

36,495

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.

Share:
36,495
Vilém Procházka
Author by

Vilém Procházka

Updated on November 22, 2020

Comments

  • Vilém Procházka
    Vilém Procházka over 3 years

    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

  • Andrew Barber
    Andrew Barber over 11 years
    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
  • hynekcer
    hynekcer almost 11 years
    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.
  • PiotrWolkowski
    PiotrWolkowski over 9 years
    It might not be the case. After quick look at this site: 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.
  • dchang
    dchang over 5 years
    BinaryLocation is to indicate chrome.exe, not chromedriver.exe seleniumhq.github.io/selenium/docs/api/dotnet/html/…