The easiest way is to use pip and VirtualEnv. Selenium also requires python 3.*.
Install virtualenv using:
$: pip install virtualenv
Create/enter a directory for your Selenium files:
$: cd my_selenium_project
Create a new VirtualEnv in the directory for your Selenium files:
$: virtualenv -p /usr/bin/python3.0 venv
Activate the VirtualEnv:
$: source venv/bin/active
You should see now see (venv) at the beginning of each bash line. Install Selenium using pip:
$: pip install selenium
Selenium comes with the FireFox driver by default.
If you want to run Selenium in google chrome, also do this:
$: pip install chromedriver
You now have a version-controlled VirtualEnv. To make sure everything is set up correctly:
Start python:
$: python
Prints out:
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Create a new webdriver (in this case, a chromedriver), and go to www.google.com:
>>> from selenium import webdriver
>>> driver = webdriver.Chrome()
>>> driver.get("https://www.google.com")
Close the driver and python interpreter:
>>> driver.quit()
>>> quit()
Deactivate the VirtualEnv:
$: deactivate
If the line driver = webdriver.Chrome()
is throwing errors:
driver = webdriver.Chrome("./venv/selenium/webdriver/chromedriver")
.