Setup your python/selenium for Web Automation
We will discuss how to setup your python/selenium envionrment for web automation. The required package it will need –
- Python / Python Editor
- Selenium/Python Library
- Browser Webdriver
Python Installation
Visit the website to download the python. http://python.org/download/
Should I download 2.7 or 3.x ?
The key difference are the add-on modules that it may support. Python 3.x may have few python module not supported.
If your automation or system environment are new to python, then it may make no difference.
If you may need to consider existing developed python system, then Python 2.x is recommended.
Installing PIP and Selenium Library
Install the PIP. PIP is the Python Package Installation manager. It will help us to install other Python add-on package easier.
Download the python script here. https://bootstrap.pypa.io/get-pip.py
Execute the following command in order
python get-pip.py |
This is to install the selenium library by using PIP.
pip install -U selenium |
Python Editor IDE
This can be optional. Though you may use any editor (vi or notepad) to edit your python source code, it’s recommended to use a Python IDE.
The Python IDE will help you to do programming easier. i.e. AutoComplete, hint, syntax check..and so on.
There are two free tools recommended here.
PyCharm
http://www.jetbrains.com/pycharm/download/index.html
PyScripter
https://code.google.com/p/pyscripter/
Chrome/IE WebDriver
If you would like to test your web automation for Chrome or IE, the addtional webdriver will need to be downloaded. The webdriver are EXE file which will be used for selenium/Python to launch and talk to browser when running the automation scripts.
ChromeWebDriver
http://chromedriver.storage.googleapis.com/index.html
IE WebDriver
https://code.google.com/p/selenium/wiki/InternetExplorerDriver
IE configuration for Selenium/python
If you are planning to test the IE browser with selenium, be sure to config the followings. Fail to do one of these will result in selenium automation testing failure in IE browser.
- Make sure “Enable Protected Mode” are all the same either on or off for all security zone (Internet, Intranet, Trusted sties, Restricted sites)
- Make sure the IE zoom setting is set to 100%. Yes it must be exactly 100% not other value.
Summary
In summary, the key steps to setup your python/selenium ready are –
Component | Noted | Source of Download |
Python | 2.7 is recommended if you are considering the support of add-on. | http://python.org/download/ |
Python PIP | python get-pip.py | https://bootstrap.pypa.io/get-pip.py |
Selenium Lib | pip install -U selenium | |
Python IDE PyCharm | It’s a Python IDE. | http://www.jetbrains.com/pycharm/download/index.html |
IE/Chrome WebDriver | It’s optional. only used if the python automation scripts will executed in IE or Chrome. | http://chromedriver.storage.googleapis.com/index.html
https://code.google.com/p/selenium/wiki/InternetExplorerDriver |
Reference of Python WebDriver
http://selenium.googlecode.com/git/docs/api/py/api.html
http://docs.seleniumhq.org/docs/
https://code.google.com/p/selenium/w/list