Friday, September 18, 2015

Setting Selenium Test Envirnment---Python Installation



In order to work with selenium using Python, First and foremost thing you need is......PYTHON. You have to have python in your machine. To install Python in your machine, follow the below steps.

Note: Make sure, that you are selecting all the files according to your system bit rate.

Installation of Python: 
Download and install Python 2.7.*. from http://python.org.  Go to the Python download page and choose a Windows x86 MSI Installer.  Choose 32 bit Python (“x86”), not 64 bit, to be compatible with the AutoItLibrary.  Note that 32 bit Python will run properly on a 64 bit system.
A quick link is: http://python.org/download/releases/2.7.6/, Choose defaults when you run python-2.7.6.msi.

Setting Environment Variables
1.   Navigate to Computer Properties Advanced system settings Environment Variables
2.   Click on “new” to add an environment System variable PYTHON_HOME and set the value as “C:\Python27” (refer to below screenshot)

3.   Add “%PYTHON_HOME%;” and “%PYTHON_HOME%\Scripts;” to your system ‘Path’. Ensure that there is a “;” at the beginning and end of the new entries in the path (unless it is the first or last entry).  Refer to the screenshot below.

To verify if Python is correctly installed on your machine, run the below command in a command (cmd) window.
Python --version
If you get the response as shown in the snapshot below, it means Python is installed in your system.


Installation of  wxPython:

Download an appropriate installer (such as wxPython2.8-win32-unicode-2.8.12.1-py27.exe) from the SourceForge project page at http://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/ and run the installer using default choices.

pip requires setuptools, so setuptools has to be installed first, before pip can be installed.
To install setuptools from scratch:
1.   Download ez_setup.py. Please follow the download instructions below:
a)   There is a location of ez_setup.py at https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
b)   Copy the code and save it in a file called ez_setup.py.  I recommend putting the file in a directory such as C:\Python27\Scripts.
c)   Navigate to the directory where you have placed ez_setup.py.
2.   Then run the following (which may require administrator access) from the folder that contains ez_setup.py using a command window:
python ez_setup.py
3.   Verify if the ‘setuptools’ are correctly installed. Once the above py file is run, at the bottom of the command prompt, look for the below message.  The version file may be more recent.
Output:
4.   Download get-pip.py.  Please follow the download instructions below:
b)   Right-click on get-pip.py and click on ‘Save link as’
c)   Download the file.  .  I recommend putting the file in a directory such as C:\Python27\Scripts. 
5.   Then run the following (which may require administrator access) from the folder that contains get-pip.py using a command window, to install the latest version of pip:
python get-pip.py
6.   To verify if PIP is correctly installed in your machine, run the below command.  You should see the output as shown below, although perhaps with a newer version number.
pip --version
Output:
7.   Then get the latest install of setuptools, by running the below command

pip install --upgrade setuptools

8.   Now navigate to Scripts directory of python installed and type the below command for Python Selenium package installation in command prompt.
easy_install selenium



Till now we have seen the process of Python Installation ,I will demonstrate Eclipse configuration in the next post.

Just go Through the following link for Eclipse configuration with PyDev:

http://seleniumautomationeasy.blogspot.in/2015/09/setting-selenium-test-environment-to.html

2 comments: