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:
- Python is favored programming language as it runs faster than Java programs.
- Python uses indentation which is easy to use rather than using traditional braces to start and end block of code while programming.
- Python is easy to code due to dynamic typing as compared to static typing in java which can increase chances of syntactical error.
- 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.
Step 2: As plug-in are installed successfully, now install “PyDev” for Eclipse and follow below procedure.
- Navigate to Search tab on Eclipse Marketplace and search for "pydev" in search box as highlighted.
- Click on install as indicated.
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.
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.
After that below window appears click on “OK” button.
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.
- Go on Browse and click on that and find python executable file "C:\Python27\python.exe with .exe extension.
- 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.
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.
You can verify whether the package is been created or not using Package Explore as attached in below screenshot.
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.
No comments:
Post a Comment