Selenium Tutorials

Selenium JARs Download and Configure in Eclipse

Selenium provides its API implementation in several programming languages like Java, Python, C#, Ruby, etc. However, in the present market Java-based bindings are most popular in the Selenium API. In this article, you will learn how to download Selenium Jars and configure in Eclipse IDE to use them in writing selenium scripts.

To Configure Eclipse IDE with Selenium WebDriver, we need to perform the following steps:

  1. Installing Java
  2. Installing Eclipse IDE
  3. Configure Eclipse IDE with WebDriver

Installing Java on your computer

Step 1: Go to the official website (https://www.oracle.com/technetwork/java/javase/index-137561.html) and click on the platform which you use.  Click on the correct OS corresponding to the specific JDK. (Windows, Mac, Linux, etc) Here, I am clicking on Microsoft Windows as mine is a Windows Operating System.

Step 2: Choose the JDK corresponds to your Operating System.

Step 3: Click on the Downloads tab.

Step 4: Click on JDK Download under Java SE 8u241

Step 5: Download the JDK exe file based on your Operating System.

Step 6: Accept the License Agreement, by clicking the checkbox “I reviewed and accept the Oracle Technology Network License Agreement for Oracle Java SE” and click Download JDK file.

Once clicking on the above exe file, it asks for oracle registration. Login with valid credentials and click on the Sign-In button. The above step will start downloading the JDK exe file automatically. This can be on your system at the bottom left of the browser window.

Steps to Install Java

Step 7: Once the download is complete, double click the downloaded .exe file to begin the JDK installation. This will start the installation process. In order to start the installation process click on the Next button.

Step 8: Select Development Tools and click on Next.

Step 9: It starts the installation and that will take a few minutes to complete.

Step 10: Next window will ask for the location where you would like to install Java on your system. You can change the location where you want to keep your folder, but it’s better to stick with the default location. Click on Next to continue.

It starts the installation and that will take a few minutes to complete.

Step 11: The dialog box confirms the last steps of the installation process. Click on the Close button to complete the Java installation process.

Installing Eclipse IDE

After installing Java let’s see how to install Eclipse IDE. The steps are almost the same for Windows, Mac and Linux operating systems.

Step 1: Go to the Eclipse official website (http://www.eclipse.org/downloads) and click the Download button option of the Eclipse IDE icon.

Note: For Windows users, if your computer is 64 bit, select Windows 64 and if you have 32 bit, select 32 bit Windows.

Step 2: Click on the eclipse-inst-win64.exe file to download.

The above step will start downloading the Eclipse exe file automatically. This can be on your system at the bottom left of the browser window.

Step 3: Once the completion of the download, run the exe file to start Eclipse installation for windows.

Step 4: In the Installer window click on “Eclipse IDE for Java Developers”

Step 5: A new window will appear once click on Eclipse IDE for Java Developers. Change the folder path to “C:/eclipse” and click on the install button.

Note: Before changing the Installation folder you need to create the folder eclipse initially in C drive.

You can see the installation process starts running

Step 6: A new window will open once after the completion of the installation. Click on the launch button in the new appeared window.

Step 7: Once you click on Launch the button it will open Eclipse IDE.

Selenium JARs Download

Generally, selenium is not installed, it is configured. We just need to download the Selenium JARs and include them in eclipse.

Step 1: Go to the official website https://www.selenium.dev/ and click on the Downloads tab. 

You will find drivers for each different language but here we choose the one for Java and click on Download link.

Once you click on the download button, it will start downloading as a ZIP folder automatically. This can be on your system at the bottom left of the browser window.

Extract the ZIP folder on to your C drive so that it can save the directory as “C:\selenium-3.141.59\”. This directory contains all the Selenium JAR files.

 

Configure Eclipse IDE with Selenium WebDriver

Step 1: Launch the “eclipse.exe” file inside the eclipse folder.

Step 2: It will ask to select for a workspace, just click on the Launch button to accept the default location or otherwise you can change the location of your choice.

This will launch the Eclipse IDE

Step 3: Create a New Java Project from File > New > Project

Step 4: Name the Project Name as “Testing” and click the Finish button

Step 5: Right Click on your given Project Name (Testing) and select New > Package

Step 6: Enter Package name testautomation and click Finish button

Once clicking on the Finish button you can see a newly created package name testautomation under project name Testing.

Step 7: Right-click on given a package name (testautomation) and select New > Class.

Step 8: Enter Class Name NewTest and check the checkbox option public static void main and click the Finish button.

Step 9: Now your Eclipse will look like as below

Step 10: Now let’s add a few lines of Selenium code without configure JAR files. It will throw us an error message when we won’t add jar files like below.

To overcome the above issue we need to add Selenium JAR files to our project.

Step 11: Right-click on Project Testing. Select Properties > Java Build Path. Select the Libraries tab and click Add External JARs button.

Step 12: Add the client-combined jar file from the selenium jars folder.

Step 13: Add all the JAR files under the libs folder.

Step 14: Click on Apply and Close button.

Step 15: Once Adding Jar files your Package Explorer will look similar to the below image. Here we need to import ChromeDriver and WebDriver classes so that errors related to Selenium classes would get disappeared.

Now our Java project is configured with selenium classes.

 

Selenium Maven Dependencies

Now a day’s most people use Maven as a build tool for Java projects. In that case, it’s very simple to import selenium jars into your project. Just we need to add the following dependencies into your pom.xml file which looks like below.

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>

Steps to follow for a New Maven project

Step 1: Open Eclipse then click on File > New > Project.

 

Step2: Select the Maven Project under the Maven category and click on the Next button.

Step 3: Select the checkbox “Use default Workspace location” and click the Next button.

Step 4: Select the option maven-archetype-quickstart and click on the Next button.

Step 5: Give Group Id, Artifact Id and click Finish button.

Step 6: You can see the created maven project in the project explorer window.

Step 7: Double click on pom.xml file and the source code get appear in the editor.

Step 8: We need to configure the selenium maven dependencies to our project. Go to the https://www.selenium.dev/downloads/ and click on here link.

Step 9: Copy and paste the below maven dependency information in pom.xml file which was provided by Selenium guys by default.

Step 10: Open pom.xml file creates dependencies tag and paste the Maven dependency code inside the created dependencies tag and save the pom.xml file.

Step 11: Expand “Maven Dependencies” under your project to confirm that selenium jars are included in the project are not.

Conclusion:  In this article, we learned how to install Java, Eclipse and learned how to add selenium jars to the newly created project and also learned how to add Selenium jars using maven.

 

 

Facebook Comments
Tags

Related Articles

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button
Close
Close