0

I am using selenium pyhthon to try and open amazon.com in google chrome, but I keep getting this error message when I run the code.

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

I have tried to search up this error on stackoverflow, but all I can find is Selenium gives "selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary" on Mac, which I cannot understand. I am using mac M1 and I have the chrome version 92.0.4515.107. My code is

from selenium import webdriver

chrome_driver_path = "/Users/asznee/selenium/chromedriver"
driver = webdriver.Chrome(chrome_driver_path)

driver.get("https://www.amazon.com")
  • Where is your Google Chrome installed , in which directory ? – cruisepandey Jul 24 '21 at 07:02
  • 1
    this may help: https://stackoverflow.com/questions/64459351/chrome-driver-selenium/64460007#64460007 please check the location of your chromedriver – Pygirl Jul 24 '21 at 07:03
  • My google chrome is /User/asznee/Desktop/Downloads/Google Chrome – Ethan Ethan Jul 24 '21 at 07:10
  • And my chrome driver is in /User/asznee/selenium/chromedriver – Ethan Ethan Jul 24 '21 at 07:12
  • selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at /User/asznee/Desktop/Downloads/Google Chrome. This is the error once I put 'options.binary_location = "/User/asznee/Desktop/Downloads/Google Chrome"' as the chrome_options – Ethan Ethan Jul 24 '21 at 07:16

3 Answers3

0

See your Google chrome is not installed in default location which is

C:\Program Files\Google\Chrome\Application

it is installed :

C:\Users\asznee\Desktop\Downloads\Google Chrome\Application 

right ?

so for solving this issue, your chromdriver.exe needs to know where Google chrome is installed :-

You can try the below code :-

options = webdriver.ChromeOptions()
options.binary_location = "/Users/asznee/Desktop/Downloads/Google Chrome/Application/chrome"
chrome_driver_binary = "/Users/asznee/selenium/chromedriver"
driver = webdriver.Chrome(chrome_driver_binary, options = options)
cruisepandey
  • 28,520
  • 6
  • 20
  • 38
  • It just gives this error selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at /Users/asznee/Desktop/Downloads/Google Chrome/Application/chrome – Ethan Ethan Jul 24 '21 at 07:53
  • I am using windows so I have that application folder, Do you happen to have the same structure ? You can change it that to the location of your Google chrome installed directory and try again – cruisepandey Jul 24 '21 at 07:57
  • My structure is just /Users/asznee/Desktop/Downloads – Ethan Ethan Jul 24 '21 at 08:09
  • Do you see Chrome launcher in Downloads ? Are you sure if there isn't folder ? – cruisepandey Jul 24 '21 at 08:36
0

there is no need to specify the path of the chrome driver just keep the chrome driver in the project just copy and paste in the project

and start initializing the web driver simply start typing with WebDriver driver = new ChromeDriver(); and enter the URL of the application and follow the code

0

WebDriver driver = new ChromeDriver();

WebDriver is having unimplemented methods

here is chrome driver is implementing these unimplemented methods

chrome driver is just the driver which you're telling the selenium to run the test on the chrome browser. you can download it on the

https://chromedriver.chromium.org/home

if you want to work with the firefox browser you use the gecko driver.