9

I just started to work with selenium web driver with chromedrivers. I am using MacOS and When I try to set the path for the chrome browser as a binary path I always face the same error saying no chrome binary at so and so path given.

import os  
from selenium import webdriver  
from selenium.webdriver.chrome.options import Options  
from selenium.webdriver.common.keys import Keys

chrome_options = Options()

chrome_options.binary_location = "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"

driver = webdriver.Chrome(executable_path = os.path.abspath("drivers/chromedriver") , chrome_options = chrome_options)

The given path in chrome_options.binary_location is correct and that is where I find my chrome browser. I also have included my chromedriver inside the project folder itself

enter image description here

/Applications/Codes/Selenium/seleniumproject/ChromeBinary.py:11: DeprecationWarning: use options instead of chrome_options
  driver = webdriver.Chrome(executable_path = os.path.abspath("drivers/chromedriver") , chrome_options = chrome_options)
Traceback (most recent call last):
  File "/Applications/Codes/Selenium/seleniumproject/ChromeBinary.py", line 11, in <module>
    driver = webdriver.Chrome(executable_path = os.path.abspath("drivers/chromedriver") , chrome_options = chrome_options)
  File "/Users/apple/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/Users/apple/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/Users/apple/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/Users/apple/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/Users/apple/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome

4 Answers 4

12

This resolved the issue

chrome_options.binary_location = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
Sign up to request clarification or add additional context in comments.

1 Comment

genius bro, remember no need to escape with '\' key for blank space guys
0

Not related to question. But you can avoid using giving path to chrome driver.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager

# chrome_options = Options()
# chrome_options.add_argument("--headless")
driver = webdriver.Chrome(ChromeDriverManager().install())#, chrome_options=chrome_options)
driver.set_window_size(1024, 600)
driver.maximize_window()

webdriver_manager can be installed using pip install webdriver_manager

Comments

-1

the binary path provided '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome' is not a valid path

try placing r'/Applications/Google/Chrome.app/Contents/MacOS/Google/Chrome' instead.

Comments

-1

Your path is not valid , you are using both forward slashes and backward slashes

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.