Install Pydev in eclipse for selenium with python

Today we are going to see the installation of Python in Eclipse, so that we can use the python as a scripting language for writing the script for selenium WebDriver. Before that let’s see why python is preferred over java.

Preference Python over Java with Selenium  

There is an observation that most of the times python is used with selenium due to following points:
  1. Python is favored programming language as it runs faster than Java programs.
  2. Python uses indentation which is easy to use rather than using traditional braces to start and end block of code while programming.
  3. Python is easy to code due to dynamic typing as compared to static typing in java which can increase chances of syntactical error.
  4. Python is compact and easy to handle as compared to Java.

How to Use Eclipse with Python

Note: you have to download eclipse first if you have not installed eclipse then go to below link.

and download the suitable eclipse version for you system

We can use Pycharm or Pydev as both are Python development Environment for Eclipse .Here we will see how we can install and configure PyDev by using Eclipse with easy steps.

Step 1: Navigate to Eclipse Marketplace by going to Help > Eclipse Marketplace and Install 'eclipse market place' plug-in once it is installed open it and validate.

Install eclipse market place

Step 2: As plug-in are installed successfully, now install “PyDev” for Eclipse and follow below procedure.
  1. Navigate to Search tab on Eclipse Marketplace and search for "pydev" in search box as highlighted.
  2. Click on install as indicated. 
Install PyDev for selenium

Step 3: After installation, below window pops-up where you mention “work with” and hit on enter then select the checkbox button 'PyDev.' which is mandatory while the second one is optional. After that hit on “Next” and lastly “Finish” button.

pydev installtion steps

Step 4: As the Plug-in and software is installed, now we need to set preferences with particular project you need to work on by navigating to Windows > Preferences > Interpreter-Python as highlighted.

pydev installation preferences

 After that below window appears click on “OK” button.

Set Pydev Preferences in eclipse

When you click on 'OK' button new window will pop-ups where you need to follow below steps.
  • Select the option Interpreter-Python under interpreter dropdown which helps in running Python script.
  • We also need to set workbench time interval as it helps to save all resource changes since last build automatically, whenever a new build is performed.
  • Then click on “Apply and Close” button which sets default Python Interpreter.
Step 5: You can also change the interpreter name by double clicking on Python Tab. In this step we will give the "interpreter name" and the "Interpreter executable file name" for Python.
  1. Go on Browse and click on that and find python executable file "C:\Python27\python.exe with .exe extension.
  2. Then click on ‘OK’ button.
Step 6: For creating New Project in Python, right click on the Package Explorer > New > and Select option others.

After clicking on Others new window appears where you can see the new Python (PyDev) project is created.

Step 7: Now, click on “Next” then below window pops-up where you select PyDev Project Folder and hit on Next followed by finish button.

Finish pydev installation

Step 8: Now you need to create a new Python package and enter the name of package you want to name and click on "Finish" button.

create a new Python package

You can verify whether the package is been created or not using Package Explore as attached in below screenshot.

Verify Pydev install in eclipse

Step 9: Now, create a new PyDev module after creating new package successfully. The module contains some Python files which are used for initialization. These files are nothing but functions which can be imported from one module to other. This will minimize the efforts of re-writing the program again. To create Module Right click on package > New >Other>PyDev module.

create a new PyDev module

No comments:

Post a Comment