Installing Selenium and fixing issues related to Chromedriver in linux

Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. Through Selenium Python API you can access all functionalities of Selenium WebDriver in an intuitive way.

Selenium Python bindings provide a convenient API to access Selenium WebDrivers like Firefox, Ie, Chrome, Remote etc. The current supported Python versions are 2.7, 3.2, 3.3 and 3.4.

Downloading Python bindings for Selenium

You can download Python bindings for Selenium from the PyPI page of selenium package. However, a better approach would be to use pip to install selenium or other python packages.

STEP 1 : Open your console and type :

 sudo apt-get install python-pip 

STEP 2 : Type the following command to install selenium binding for linux.

 sudo pip install selenium 

STEP 3 : Type or paste the following code in your favorite text editor.

from selenium import webdriver

driver = webdriver.Chrome() # you can use Firefox or PhantomJS

STEP 4 : Open terminal and type

 cd you/path/to/code/

and hit Enter.

STEP 5 : If the chrome or chromium browser open after hitting enter. You can continue learning selenium. But if you see the following result :

driver = webdriver.Chrome()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/", line 61, in __init__
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/", line 73, in start
os.path.basename(self.path), docs_msg)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see

. Then follow the next step.

STEP 6 : Goto ChromeDriver Storage and download the file -> save it -> extract the file on Desktop.

STEP 7 : Open Terminal ( CTRL + ALT + T ) and type

 cd desktop 

STEP 8 : Before moving the file to make it available, change the properties of the file, and for that, follow the steps given below. Screenshot from 2015-10-18 23:49:45 Now, type

 sudo mv chromedriver /usr/bin 

STEP 9 : Now, for sake of convenience make it executable using the following command, first type :

 sudo cd /usr/bin 


 chmod +x webdriver 

STEP 10 : Run the above python code, again. Or use another code to test it, which is :

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
assert "No results found." not in driver.page_source

Boom 😀 It runs without giving any error 🙂


One thought on “Installing Selenium and fixing issues related to Chromedriver in linux

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s