1

I have the following script

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

opts = Options()
opts.binary_location = "/Applications/Chrome.app/Contents/MacOS/Google\ Chrome"
browser = webdriver.Chrome(chrome_options=opts)
browser.get('0.0.0.0:3500')

assert 'Django' in browser.title

I get the following error after interrupting the program

$ python3 functional_tests.py 
Traceback (most recent call last):
  File "functional_tests.py", line 6, in <module>
    browser = webdriver.Chrome(chrome_options=opts)
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at /Applications/Chrome.app/Contents/MacOS/Google\ Chrome
  (Driver info: chromedriver=2.23.409710 (0c4084804897ac45b5ff65a690ec6583b97225c0),platform=Mac OS X 10.11.6 x86_64)

I have chrome installed on osx. And I know the path to the chrome binary in the script is correct. What may be wrong?

2
  • 1
    It looks like you need to install the ChromeWebdriver on you mac. kenst.com/2015/03/installing-chromedriver-on-mac-osx Commented Sep 9, 2016 at 20:55
  • chromedriver is installed via homebrew brew install chromedriver is on the path as I can execute chromedriver from the commandline as well. Commented Sep 9, 2016 at 20:59

1 Answer 1

2

Try adding the path to your chromedriver binary when you instantiate webdriver.Chrome()

browser = webdriver.Chrome('path/to/my/chomedriver', chrome_options=opts)

The official documentation suggests that you "include the path to ChromeDriver when instantiating webdriver.Chrome" in addition to including the chromedriver location in your PATH variable when you are using it in Python.

If you do not know the location of chromedriver, you can execute brew info chromedriver to see the path in addition to other information.

Sign up to request clarification or add additional context in comments.

6 Comments

no dice. Adding browser = webdriver.Chrome('/usr/local/bin/chromedriver', chrome_options=opts) gives the same error I reported in the question.
@HarryMoreno have you tried without providing the path to the chrome binary (i.e., getting rid of the chrome_options argument)?
without providing the path I get selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
@HarryMoreno, one last thing to try: set opts.binary_location to: /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome I have seen this path referenced in multiple places (note the difference between this and the path you use).
Sorry, I am out of ideas. I have more experience working with these things on Linux. Hopefully someone else will have a solution for you.
|

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.