Configure Selenium WebDriver with Java, Maven and Eclipse

Selenium 4 Setup With Java, Maven, Eclipse | Install And First Test | Selenium 4 Installation

Introduction: Selenium, the popular open-source automation testing tool, has been widely adopted by testers and developers around the world. With the recent release of Selenium 4, exciting new features and improvements have been introduced to enhance the testing experience. In this blog post, we will guide you through the setup process of Selenium 4 with Java, Maven, and Eclipse, and demonstrate how to perform your first test using this latest version.

You can also watch the video for completing the setup:

Prerequisites: Before we begin, make sure you have the following prerequisites in place:

  1. Java Development Kit (JDK) installed on your system.
  2. Maven installed and configured.
  3. Eclipse IDE (or any other preferred Java IDE) installed.

Step 1: Create a Maven Project, let's create a new Maven project in Eclipse:

  • Open Eclipse and click on "File" in the menu bar, then select "New" and click on "Maven Project."
  • If you don't see Maven Project, then click on other at the bottom and select Maven Project
  • Choose "Create a simple project" and click "Next."

  • Enter a Group Id and Artifact Id for your project
  • Click "Finish" to create the project structure.

  • Two Folder will be created under project
  • src/main/java and src/test/java
  • Delete src/main/java safely (optional)
  • Delete the file under the src/test/java location

Step 2
: Add Selenium 4 Dependency.

Now that we have our project set up, we need to add the Selenium 4 dependency to our project's pom.xml file:

  1. Locate the pom.xml file in your project's structure.
  2. Open the pom.xml file and navigate to the <dependencies> section
  3. Navigate to ""
  4. Copy the selenium-java dependency latest version
  5. Paste them in pom.xml under dependencies
<!-- -->

Note: At the time of writing this blog post, Selenium 4 is at version 4.10.0. Make sure to check for any updates and use the latest stable version available.

7. Save the pom.xml file to update the project's dependencies.

Step 3: Set Up Test Case

Let's now create a simple test case to verify our Selenium 4 setup:

  • Create a package or use the package created by default
  • Create your First Test Class
  • Import the necessary Selenium 4 packages

import org.openqa.selenium.WebDriver;

Step 4: Run the Test Finally, let's run our Selenium 4 test case:

  1. Right-click on the Java class and select "Run As" -> "Java Application."

  2. If the test runs successfully, you should see the website open in the browser window.

Congratulations! You have successfully set up Selenium 4 with Java, Maven, and Eclipse.

Categories: : Selenium WebDriver Java