Selenium with Python

Selenium with Python

Selenium is a popular test automation tool which supports multiple programming languages, like Java, Python, Perl, Python, C#, Ruby set of languages. Selenium with Java is one of the most popular implementations of it, but selenium with python is also gaining significant momentum, because of the steep rise in the popularity of python as a language, which as shown in diagram below occupies a significant market now.



What is Python

Python is a high level object oriented scripting language. It uses English like syntax makes it an easy language to adapt to by programmers and non programmers alike. This also reduces the complexity of maintenance. It also supports modules and package, encouraging code modularity and reuse. There is an old but still relevant article on comparing python with other programming languages -, a must read.

Hello World Program in Python vs Java

Lets have a look at a simple program, which shows the complexity of coding in java, vs that in python by writing a simple program of Hello World

Hello World in Python


Hello World in Java


We can see the level of complexity of writing code is greatly reduced with Python. With the new age practices coming into picture, there is a tendency now to use programming languages which are more natural and similar to English like language. Complexities like case sensitive, usage of brackets, semi colons are now bound to diminish and someday disappear in oblivion.

System Setup

To use Selenium with Python, we need to first have python in our system. So we please use the following steps to set the system for usage of Python with eclipse for functionally testing web application using selenium.

a.       Install Python 3.x series from here -

b.      Set Python path, in the path variable of windows, generally python can be found in c:usersusernameappdatalocalprogramspython folder.

c.       Install PyDev from eclipse market place -

d.      Install selenium using either pip install selenium on command prompt

e.      Or use easy_install selenium, to install selenium on system as a python module

Once the system is set with the above steps, you can now proceed to write a program to test the application at hand.

Selenium with Python

The following link, displays the basic steps to start using selenium with python -, with excellent example of each step. Let us also try to see a script for using python with selenium for the following scenario –

Login Logout on eCommerce Application –

a.       Open the application –

b.      Click on the my account link

c.       Type user name on the email address text box –

d.      Type password on the password field – “USER123”

e.      Click on the sign in button

f.        Validate “My Account Information” on page

g.       Click on the log off link

h.      Click on the continue button

The script for the above steps will be as follows – 



The above program is the first step to automation using selenium with python. Hope you like reading it!


No comments

Leave a reply

Your email is never published nor shared. Required fields are marked *