Running Selenium WebDriver python bindings in chrome
You need to make sure the standalone ChromeDriver binary (which is different than the Chrome browser binary) is either in your path or available in the webdriver.chrome.driver environment variable.
see http://code.google.com/p/selenium/wiki/ChromeDriver for full information on how wire things up.
Edit:
Right, seems to be a bug in the Python bindings wrt reading the chromedriver binary from the path or the environment variable. Seems if chromedriver is not in your path you have to pass it in as an argument to the constructor.
import osfrom selenium import webdriverchromedriver = "/Users/adam/Downloads/chromedriver"os.environ["webdriver.chrome.driver"] = chromedriverdriver = webdriver.Chrome(chromedriver)driver.get("http://stackoverflow.com")driver.quit()
For Linux
Check you have installed latest version of chrome brwoser->
chromium-browser -version
If not, install latest version of chrome
sudo apt-get install chromium-browser
get appropriate version of chrome driver from here
Unzip the chromedriver.zip
Move the file to
/usr/bin
directorysudo mv chromedriver /usr/bin
Goto
/usr/bin
directorycd /usr/bin
Now, you would need to run something like
sudo chmod a+x chromedriver
to mark it executable.finally you can execute the code.
from selenium import webdriverdriver = webdriver.Chrome()driver.get("http://www.google.com")print driver.page_source.encode('utf-8')driver.quit()
Mac OSX only
An easier way to get going (assuming you already have homebrew installed, which you should, if not, go do that first and let homebrew make your life better) is to just run the following command:
brew install chromedriver
That should put the chromedriver in your path and you should be all set.