Friday 22 November 2013

Test setup for automation in python selenium

Welcome to my selenium blog.  I will be posting a variety of topics focused on selenium test automation.
This blog will show you step by step installation of selenium automation using Python
Python programming language is used to automate functional tests using Selenium WebDriver.
Step 1 : To run selenium test cases in python, you need python on your machine. You can download Python 3.3 installer from
The python-3.3.2.msi setup is 19.5 MB  in size.
Step 2 : You need to import different python libraries in your project. PyPI (Python Package Index) is a repository of software for the Python programming language.Setup tool is require to install the python bindings.

You can install setuptools by downloading ez_setup.py script.
Create easySetupTool directory under python installer. Then copy the script on your machine. 

Run the command:
C:\Python33\easySetupTool>python ez_setup.py

Once installation is complete, you will find an easy_install.exe program in your Python Scripts sub directory. Add this directory to your PATH environment variable.

You can also use pip command to download any package from python binding.
Step 3 : You can download Python bindings for Selenium from the PyPI page for selenium package.
The selenium package is used to automate web browser interaction with python.
Download it from here .
Step 4 : Create folder name selenium c:\selenium.
Step 5 : Unzip selenium webdriver and extract  "selenium-2.37.2"  in selenium folder.

Step 6 : Run setup.py script on command prompt as given below.
python C:\Python33\selenium-2.37.2\setup.py install

Instead of step 3, 4,5 and 6 you can directly download selenium package as:
run the command 
C:\Python33\Scripts>easy_install selenium
The setup is ready now. You can verify it by running any test script captured using selenium IDE.
Record any testcase using Selenium IDE and then export the test case as python 2.0 selenium webdriver. Save the script as test.py python script.
Run the test script as :
D:\PythonScripts>python test.py
C:\Python33\lib\site-packages\selenium-2.37.2-py3.3.egg\selenium\webdriver\firefox\firefox_binary.py:95: ResourceWarning: unclosed <socket.socket object, fd=284, family=2, type=1, proto
=0>
  while not utils.is_connectable(self.profile.port):
.
----------------------------------------------------------------------
Ran 1 test in 51.239s
OK
Ok indicates, your test is run successfully.

No comments:

Post a Comment