I am running selenium through anaconda on my mac. To be able to choose Chrome as my webdriver I need to download the latest chromedriver. But I can't figure out where to put the file for it to be in path. If I just run
driver = webdriver.Chrome()
WebDriverException: Message: unknown error: cannot find Chrome binary
Should I put chromedriver in anaconda/lib/python2.7/site-packages/selenium/webdriver/
and if so how do I specify selenium to use it?
I know it has to be something simple, since I have already set up chromedriver on my other computer like a year ago, but I don't have access to it right now.
EDIT: tried this
import os
from selenium import webdriver
chromedriver = "/Users/username/Downloads/chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.get("http://stackoverflow.com")
driver.quit()
Got this error:
WebDriverException: Message: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.23.409710 (0c4084804897ac45b5ff65a690ec6583b97225c0),platform=Mac OS X 10.11.6 x86_64)
The simplest solution is to install chromedriver as suggested by @bgodr:
conda install -c conda-forge python-chromedriver-binary
Then at the top of your code, add the following import statement to update your PATH variable appropriately:
import chromedriver_binary
The easiest would be to install chrome-driver via anaconda (especially when running on a machine where you don't have permissions to install chrome-driver from .deb package)
conda install -c conda-forge python-chromedriver-binary
(updated based on comment from bgoodr (https://stackoverflow.com/users/257924/bgoodr) - please vote his comment below ).
from selenium import webdriver
driver_path = '/path to chromedriver.exe/'
driver = webdriver.Chrome(driver_path)
driver.get('somewebsite')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With