Selenium Setup A-Z

Selenium Webdriver setup for Python is made available through Python Binding. This binding is facilitated by making use of available Python Installer and Easy Install Setup tool. Let us proceed with first automated Selenium Webdriver test using Python.
Step 1: Setup Python Environment
Python environment can be set in your system by downloading installation file available here (latest available version for 64 bit Windows as on writing this post is Python 2.7.8 Windows X86-64 MSI Installer)
Note: Download and install python installer as per your system requirement

Check the correctness of python environment setup by navigating to recently installed python directory and simply tying command ‘python‘ in command prompt.
Step 2: Setup Environment Path
Add the following path in system path:
1.  C:\Python27;
 2. C:\Python27\Scripts
Windows 8 users
1.       From the Desktop, right-click the very bottom left corner of the screen to get the Power User Task Menu.
2.       From the Power User Task Menu, click System.
3.       Click the Advanced System Settings link in the left column.
4.       In the System Properties window, click on the Advanced tab, then click the Environment Variables button near the bottom of that tab.
5.       In the Environment Variables window (pictured below), highlight the Path variable in the "System variables" section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon as shown below.

C:\Python27;C:\Python27\Scripts



Note: You can edit other environment variables by highlighting the variable in the "System variables" section and clicking Edit. If you need to create a new environment variable, click New and enter the Variable name and Variable value.
Windows Vista and Windows 7 users
1.       From the Desktop, right-click the Computer icon and select Properties. If you don't have a Computer icon on your desktop, click the Start button, right-click the Computer option in the Start menu, and select Properties.
2.       Click the Advanced System Settings link in the left column.
3.       In the System Properties window, click on the Advanced tab, then click the Environment Variables button near the bottom of that tab.
4.       In the Environment Variables window (pictured below), highlight the Path variable in the "System variables" section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon as shown below.

C:\Python27;C:\Python27\Scripts


Note: You can edit other environment variables by highlighting the variable in the "System variables" section and clicking Edit. If you need to create a new environment variable, click New and enter the Variable name and Variable value.
Windows 2000 and Windows XP users
The path is now managed by Windows 2000 and Windows XP and not the autoexec.bat or autoexec.nt files as was done with earlier versions of Windows. To change the system environment variables, follow the steps below.
1.       From the Desktop, right-click My Computer and click Properties. If you don't have a My Computer icon on your desktop, click the Start button, right-click the My Computer option in the Start menu, and select Properties.
2.       In the System Properties window, click on the Advanced tab.
3.       In the "Advanced" section, click the Environment Variables button.
4.       Finally, in the Environment Variables window (as shown below), highlight the Path variable in the Systems Variable section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon as shown below.

C:\Program Files;C:\Winnt;C:\Winnt\System32


Note: You can edit other environment variables by highlighting the variable in the "System variables" section and clicking Edit. If you need to create a new environment variable, click New and enter the Variable name and Variable value.

Step 3: Install Python specific Selenium Package
Selenium bindings are readily available as package in Python. Python packages can be installed using any of methods described here.
We will use second and easiest method ‘Installing Globally’ of Selenium package installation. It requires setuptools installation and PATH definition in environmental variables of your system settings.
Setuptools as compressed version can be downloaded from here (latest available version as on writing this post is setuptools 0.9)
Uncompressing the setuptools downloaded and double click python file named ‘ez_setup’ available in extracted folder. This setup in turn will make easy_install.exe’ executable file automatically added to Scripts folder of python directory installed in step (1). Include exact path of Scripts directory in PATH of environmental variable.
Now navigate to Scripts directory of python installed and type the below command for Python Selenium package installation in command prompt.
‘easy_install selenium’

Allow command prompt to complete Python Selenium package installation.
Step 4: Installing Internet Explorer Server and Chrome Server
For running internet explorer and chrome you need to install the servers. User can download these from the following links:
IE :-
Chrome:-
Store it in Window executable path for example C:\Python27


1 comment:

Realtime Experts said...

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.DataScience with Python Training in Bangalore