Install and Configure Eclipse with Selenium WebDriver

Download Eclipse:

  1. Go to https://www.eclipse.org/downloads/
  2. Download Eclipse IDE for Java EE Developers, 250 MB zip file and extract it using win rar or with any other software. 
Download Java:
  1. Go to https://www.java.com/en/download/
  2. Download java installer by clicking on “Free Java Download” 
  3. Open installer and finish the installation by clicking next and next button (Instructions). 

Download Selenium Web Driver:
  1. Goto http://docs.seleniumhq.org/download/
  2. Download java jar files by clicking on download Button and extract zip file. 



To configure Eclipse with Selenium WebDriver, we need to perform the following activities:



  • Launch the Eclipse IDE & Create a Workspace 
  • Create a new Project 
  • Create a new Package 
  • Create a new Class 
  • Add External libraries to the project 

1) Double click on ‘eclipse.exe‘ to start eclipse. First time when you start eclipse, it will ask you to select your workspace where your work will be stored as shown in below image.


2) Create a ‘working directory’ for all of your projects. Think of it like ‘My Documents’ in the Windows operating system. It’s a folder which contains a lot of your documents, but there’s nothing to prevent you from creating another folder called ‘My Other Documents‘ (for instance) to house other documents.

Typically you only need one workspace, and you can think of it as your ‘My Documents‘ for Java code. If you wanted to, you could have more than one, but chances are you won’t have a use for more. I like to choose my own workplace location and will place all my ToolsQA tutorial projects under it.

You can change it later on from ‘Switch Workspace‘ under ‘File‘ menu of eclipse. After selectingworkspace folder, Eclipse will be open.




3) You may see the window like this, this is the Welcome window for Eclipse. You may close this window.


Create a new Project

Projects: A collection of related code. Generally speaking, each project encompasses one independent program. Each programming assignment you do will typically require its own project.

Once you’ve established your workspace, you’ll want to create a project and begin writing code. In Eclipse, projects are the next-smallest functional unit after workspaces, but where you might have only one workspace, you will usually have several projects inside one workspace.

1) Create new Java Project from File > New > Project .



2) Select Java Project and click Next.



3) Give your Project name ‘OnlineStore‘ as shown in below given figures. Click on Finish button.



4) You may or may not see this message but if in case you get any, check Remember my decision and click on Yes.



Now your new created project ‘OnlineStore‘ will display in eclipse project explorer.


Create a new Package


1) Right click on Project name ‘OnlineStore‘ and select New > Package.



2) Give your Package name ‘automationFramework‘ and click on Finish button.


Now you can see a new package with name ‘automationFramework‘ under project name ‘OnlineStore‘.

Create a new Class

Now that you have a project set up, you’re going to want start writing some new classes

1) Right click on Package ‘automationFramework‘ and select New > Class.



2) Give your Class name ‘FirstTestCase‘, check the option ‘public static void main‘ and click on Finish button. This will bring up totally a sweet class creation window.



Note: In case of not creating class for Main test case, please do not click ‘public static void main’. We need to select it only in case of writing test cases which we are going to execute and from where we call other classes. For functional classes, POM classes or any other classes we don’t need this to be checked.

3) Now your Eclipse window will looks like bellow.


Add External Jars to Java build path

Now you need to add Selenium WebDriver’s Jar files in to Java build path.

1) Right click on Project ‘OnlineStore‘ > Select Properties > Java build path. Then navigate to Librariestab and click Add External JARs.



2) Add Selenium Java jar, you may add the source file too.



3) Add all the jars from the libs folder as well.



4) Click OK.


That’s all about configuration of WebDriver with eclipse. Now you are ready to write your test script in eclipse and run it in WebDriver.