Install Python

We have to install python in our operating system to use selenium python bindings our project.

1. Navigate to https://www.python.org/downloads/

2. Download the latest version of the Python or a stable version, for this tutorial we will be using python 3 (version above 3 are considered as 3 in general terms)
download-python-selenium

3. Install the python installer (i am on windows 10 operating system), and select add path
python-installer-selenium

4. After installing, open cmd and type python, you should get version and >>> python editor. If you get them then your python installation is successful.

cmd-to-check-python-installtion

Install Selenium

1. We should have python installed in your system before you try to install selenium

2. You can install selenium just by typing following command on cmd (not on python editor) : pip install -U selenium
pip-install-selenium

3. Now open python editor just simply entering word python on the command prompt.
4. Below command will not throw any exception if your selenium is installed successfully from selenium import webdriver

Note : Only incase if you are not able to install the selenium using pip command then only try below steps otherwise ignore the below steps.

Install selenium Manually :

Sometimes pip command fails to install selenium either due to proxy issues, or due to system configurations issues, in that we have to use below steps to install selenium.

1. Navigate to https://pypi.python.org/pypi/selenium
2. Click on the download button
selenium-pi-python

3. Download the applicable format based on your operating system, below image shows for windows operating system
selenium-tar-python

4. Extract the downloaded zipped file to your local system, and content should look like below.

5. Open command prompt/terminal and navigate to that the unzipped folder.

6. Enter following command to install selenium : python setup.py install or python install setup.py
7. Now open python editor just simply entering word python on the command prompt.
8. Following command will not throw any exception if your selenium is installed successfully from selenium import webdriver

Install pyDev with eclipse

We cannot code all the thing in the python editor, which is in command prompt. To edit python code easily we have to use an IDE for development. In this tutorial I will be using Eclipse with PyDev.

1. After installing Eclipse, Goto Help >Eclipse marketplace
market-place-selenium-python

2. Now search for "pyDev" and install the software
pydev-selenium-python

3. Accept the License and Restart the eclipse.
4. We have to open PyDev perspective to edit python code, Window > Perspective > Open Perspective > Other and choose PyDev
open-perspective-python-selenium

pydev-perspective-python-selenium

5. Create first Project, File > New > PyDev Project
pydev-first-project-selenium

6. When we use python for first time, we have to set the interpreter, click to configure the interpreter.
configure-interpreter-python-selenium

7. Click on Auto-config option, and then finish the creating project wizard.
pydev-package-python-selenium

8. Right click on the python project and Create new Pydev Module, and select blank
pydev-package-python-selenium

9. Enter following command in coding area and Click run button in eclipse. from selenium import webdriver
10. You can choose how you want to run either Just python program or as UnitTest Program
python-run-test-first-selenium

Console on PyDev

Unlike other programming languages, Python provide live editor. which is you can control thr browser entering command by command.

I am not talking about debugging, Debugging is a process where you will checkpoint and run the coomplete program step by step to understand the flow and error

Python console gives the ability to run a live command, for Example : I have opened browser and I Opened Google.com but I realize i want to open Bing.com, now i donot have to stop the program as i am in live editor i just change the commands.

lets see how to open Live console :

1. Open Eclipse console.

2. On Right hand corner, you can find a icon to like rectangagle with + sign, click it.

3. Choose PyDev Console
pydev-console-selenium

4. Select Console for current Editor
console-for-current-editor

5. Now you have live console and type the commands that you want to use.
pydev-console-selenium-live

About Author

Myself KarthiQ, I am the author of this blog, I know ways to write a good article but some how I donot have the skills to make it to reach people, would you like help me to reach more people By sharing this Article in the social media.

Share this Article Facebook
You can also share knowledge by Adding a topic here


Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions
Copyright © CherCher Tech