launch selenium with python on osx
<p>I have the following script</p>

<pre><code>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
</code></pre>

<p>I get the following error after interrupting the program</p>

<pre><code>$ python3 functional_tests.py 
Traceback (most recent call last):
  File "functional_tests.py", line 6, in &lt;module&gt;
    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)
</code></pre>

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

<p>Try adding the path to your <code>chromedriver</code> binary when you instantiate <code>webdriver.Chrome()</code></p>

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

<p>The <a href="https://sites.google.com/a/chromium.org/chromedriver/getting-started" rel="nofollow">official documentation</a> suggests that you "include the path to ChromeDriver when instantiating webdriver.Chrome" <em>in addition to</em> including the <code>chromedriver</code> location in your <code>PATH</code> variable when you are using it in Python. </p>

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

python osx selenium