Configure Eclipse with Selenium WebDriver
Selenium Installation

Configure Eclipse with Selenium WebDriver

Now that you have downloaded Java, Eclipse and Selenium Webdriver – let’s see how to configure Eclipse with Selenium WebDriver. Basically what we need to do is…

Configure Eclipse with Selenium WebDriver

  1. Create a workspace in Eclipse
  2. Create a New Project
  3. Create a New Package
  4. Create a New Class
  5. Add external libraries to the project

Create a workspace in Eclipse

  1. Launch Eclipse (eclipse.exe).

2. When you launch eclipse the first time – you will notice a popup asking you to select a directory as a workspace. When you develop Java applications in Eclipse, it stores all the created files in a directory called “workspace“. It’s nothing but a folder where all your eclipse data (including code) will be stored.

Launch Eclipse

3. You can just use the default location or specify your preferred location.

4. Eclipse launched successfully

Launch Eclipse

Create a new Project

Now that you’ve got Eclipse up and running, it’s time to create your first Java project. Hope you know what a project is? No? The next logical unit within workspace. A single workspace can have multiple projects. You can think of project as different automation assignments – a set of related code.

1. Select File > New > Java Project

Eclipse New Project

2. Enter a Project Name. Here we have given ‘SeleniumTutorial’ as the project name. As you can see, the Java environment to be used for this project is selected by default under JRE section.

Eclipse Java Project

3. Click Finish and your first project is ready for experiments 🙂

Eclipse New Project

Create a new Package

1. Select your project. Select File >> New >> Package

Eclipse New Package

2. Enter the package name (e.g. automationPackage) >> Finish

3. A new package ‘automationPackage’ is now created under the project ‘SeleniumTutorial

Eclipse New Package

Create a new Class

Now it’s time to get started. Let’s create a class within the newly created package.

1. Right click on package >> New >> Class

Eclipse New Class

2. A ‘New Java Class’ window is displayed. Enter the Class name (e.g. FirstScript) >> Select the public static void main(String[] args) checkbox >> Click Finish

Eclipse New Class

public static void main(String[] args) – It defines that this will be your main class from where other classes / functions will be called.

3. Your FirstScript.java file is now ready for programming.

Eclipse First Class

Add Selenium WebDriver External Jars to Java build path

Now we are ready with Eclipse & Java. But wait a minute, where is Selenium? Yeah! You need to add Selenium WebDriver’s Jar files in to Java build path.

1. Right click on ‘SeleniumTutorial’ >> Select Properties >> Java Build Path >> Libraries tab >> click ‘Add External JARs…

Eclipse Selenium Webdriver

2. Select & Add the Selenium Java jar file

Eclipse Selenium Webdriver Jar files

3. Select all the jar files for the lib folder as well >> Open

Eclipse-selenium-webdriver-jar-files

Whoa! You have successfully learned how to configure Eclipse with Selenium WebDriver, i.e. you are all set for Selenium WebDriver automation scripting in Java using Eclipse 🙂

Save

Save

Save

Save

Leave a Reply

Your email address will not be published. Required fields are marked *