In the Previous Tutorials, we spent time setting up our system for Selenium.
Before we dig deeper into the Selenium world, wouldn’t it be interesting to jump-start with our very first Selenium WebDriver script? How about creating a small Selenium script, execute it and enjoy the show?
In this tutorial, we will learn the following –
- Creating a new Java project through Eclipse IDE.
- Configuring project to include Selenium JAR file
In the Next Tutorial, we would continue it and write and run our very first Selenium WebDriver script.
Let the show begin…
- Launch eclipse. Follow the last two pointers of this Previous Post if you forget how to open eclipse.
- Go to File -> New -> Java Project
- In the next screen, enter the Project name. We have entered ‘teach-me-selenium-java’.
- Click Finish.
- Now, under Project Explorer(left pane), right-click over ‘teach-me-selenium-java’ and select ‘New -> Class’.
If Project Explorer is not opened you can open it by going to Windows->Show View->Project Explorer. Once it is opened perform the previous step.
Enter following details –
- Package – com.teachmeselenium
- Name – MyFirstSeleniumScript
- Select the checkbox for ‘public static void main’ and Click ‘Finish’
Now we need to include selenium dependencies with this project. We downloaded those files in the Previous Tutorial.
We will add all selenium JARs to this Project’s build-path.
- Right-Click on the Project and select Build Path.
- Configure Build Path
- Select ‘Add External Jar’
In File Browser, go to the folder where you have stored the Selenium-Java client. Select the file “client-combined-3.0.1-nodeps” under the parent directory and click on “Open”.
Similarly, add all other files in the “lib” folder.
In the Previous Tutorial, we spent our of time in setting up our system for Selenium.
In this tutorial, we’ll be involved in the following activities –
- Getting familiar with PyDev perspective in Eclipse
- Create a new PyDev project
- Configure appropriate Python interpreter.
Wait a moment. I have created lots of Java project in eclipse. But I am not getting any option to create a Python project.
Have patience dude. That is why we are writing a separate python tutorial here. When we need to work on Python in Eclipse we’ll have to make sure PyDev perspective is selected.
This is how we can do that –
- On the top-right corner of Eclipse, there is an icon to open perspective. Click over there or you can go through the menu – Windows -> Perspective – > Open Perspective -> Other
- Select PyDev from the list and click OK –
- PyDev perspective is selected. You may notice a new menu item in Eclipse for Pydev.
Create a new Python project in eclipse
- Select File -> PyDev Project
- In the next screen enter project name as “TeachMeSelenium”.
Throughout this website we would be using a single PyDev project named as “TeachMeSelenium”.
- Select your interpreter version from the list. We have selected 3.6 as we downloaded Python 3.6.
- Click on the link “Please configure an interpreter before proceeding” to configure the interpreter.
- In the following screen click on “Quick Auto-Config”.
- Click “Finish”.
Let’s create a module to write our first Selenium script
- Right-click over the project “teach-me-selenium-python” and select New -> PyDev Module
- Leave Package name empty and enter Module name as “ch1_first_selenium_script” and click “Finish”.
- If Eclipse prompts to select a template, choose Empty and click OK.
You are driving me nuts. Just to create a damn python project I’ll have to perform so many steps?
Cooldown dear. Configuring interpreter is just a one-time setup. As PyDev was used for the first time in our newly setup Eclipse, we had to configure interpreter. From next time you just need to make sure you are on PyDev perspective and create a new PyDev project.
To summarize, in this tutorial we were involved in the following activities –
- Getting familiar with PyDev perspective in Eclipse
- Create a new PyDev project
- Configure appropriate Python interpreter.
- Created a Python package and module
Congratulations!!!
We are done with setting an Eclipse Project that we’ll use to write our First Selenium Script. We will continue it in the Next Tutorial.
also pls explain why we do these configurations
Sneha, Selenium server standalone jar contains the APIs for both WebDriver and RC… So to call any WebDriver or RC functions we need the JAR to be configured.
Hello Shadab,
Thanks for this excellent tutorials. I need to talk to you can you please provide your telephone number.
Azhar
Thanks Azhar 🙂 …. You can drop me an email at contact.teachmeselenium@gmail.com and we can discuss in detail …
It is fixed now. Thanks for pointing
Hi Shadad-
I have a problem setting up build path .Seems like the selenium Jar file got corrupted.Can you please help me out. Thanks!
Kishore… what exactly is the issue that you are facing.. how you came to the conclusion that the selenium Jar file got corrupted. I wont be able to help until you provide all details. For now, you can remove that JAR, get the latest one from seleniumhq.org and try to add it to build path..