selenium and testing setup with maven

Selenium and Testng setup with maven – Why do we need Maven?

Selenium and Testng setup with maven! At the present time, Maven is the best dependency management tool, a project created by Maven is easy to manage transport. Selenium is a wide browser automation tool while TestNG is the best testing framework that provides an enormous number of methods to assert actual results with the expected result. In other words, Selenium and TestNG with maven is the most popular combination in Industries. All things considered, this tutorial helps you in maven project creation, adding Selenium and TestNG Dependency. Also, one sample test is written to ensure correct installation.

In this tutorial of performing selenium and testng setup with maven, we guide you to do complete Selenium and TestNG set up and also write the first selenium test. This tutorial explained each step with a clear snapshot which helps you to do this setup independently.


  1. Most important, one Machine with 32-bit or 64-bit operating system and min RAM 4 GB
  2. Java should be Installed
  3. Eclipse should be installed on your machine

How to check the Java version or Installation in cmd?

Steps to check Java Installation: Open command prompt and type “java -version” and enter.

Check java version

Install Java If not already installed on your machine:

If java is not installed on your machine then read this tutorial Step by Step tutorial for Java installation


How to check Maven Installation or version in cmd?

Steps to check Java Installation: Open command prompt and type “mvn -version” and enter.

Check maven version
If Maven is not installed on your machine then read this tutorial: Step by Step Tutorial for Maven installation


Selenium and Testng setup with Maven – How to install or setup Selenium?

Check below how to install Selenium:

  • At first, go to Desktop and click on the Eclipse icon to open eclipse
Open Eclipse IDE
  • Select workspace
Eclipse launcher
  • Create Selenium Project (similar to Maven Project): Go to File> New and click on Project
Create Java Project
  • Select a Wizard: To create Maven Project click on “Maven Project” and then click on Next
Maven project
  • Click on “Next” on “New Maven Project” window
  • Select Archetype – maven-archetype-quickstart and click on Next
Select Archetype for maven project
  • Specify project archetype parameters and click on Finish.
Maven archetype parameters
  • Click on Project and open POM.xml
  • Add Selenium, TestNG, and WebDriverManager Maven Dependencies

When we add a dependency in POM.xml then Maven automatically downloads jar and builds in your Project.

Selenium Dependency: (Current Stable Version) – To add in POM.XML

<!-- -->

TestNG Dependency: (To add in POM.XML)

<!-- -->

WebDriver Manager Dependency: (To be added in POM.XML) – We use WebDriverManager to download browser dependency automatically. To know more about WebDriver Manager refer our this detailed blog- WebDriver Manager in Selenium

<!-- -->
<dependency> <groupId>io.github.bonigarcia</groupId>

POM.XML file dependencies for WebDriver Manager, TestNG, and Selenium:

<project xmlns=""
<version>3.8.1</version>	<scope>test</scope>
<!-- -->
<dependency>	<groupId>org.seleniumhq.selenium</groupId>	
<!-- -->
<groupId>org.testng</groupId>	<artifactId>testng</artifactId>
<version>7.1.0</version>		<scope>test</scope>
<!-- -->
<dependency>		<groupId>io.github.bonigarcia</groupId>		<artifactId>webdrivermanager</artifactId>		<version>3.8.1</version>
  • Right-click on Project, go to Maven and click on “Update Project”.
Maven Update Project
  • Install TestNG Plugin in Eclipse: Go to Help and navigate to “Eclipse Marketplace” and install TestNG Plugin
Testng plugin - Eclipse Marketplace

Click on “Install” to install “TestNG for Eclipse”.

TestNG for Eclipse
  • Create a test package and then create one LoginTest class
package Test;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;
import io.github.bonigarcia.wdm.WebDriverManager;
import junit.framework.Assert;
public class LoginTest {
public void LoginTest() {
WebDriver driver = new ChromeDriver();
// driver.get method used to naviagte to website
// maximize browser size
// Assert Website Title with Expected
String title =driver.getTitle();
		Assert.assertEquals("Welcome: Mercury Tours", title);
// Close Browser
  • Run Test as Test as “TestNG Test”. Now your test run and browser open perform the test and verify the result.
Run As TestNG

Console Output:

  • Lastly, right-click on Project and Refresh Project (Press F5) and go to test-output Folder and open emailable-report.html file.
Test Report

Great! Now you have created Selenium and TestNG Project with Maven. And also you successfully write one test, executed and TestNg Report generated.

Hope these simplified steps boost your confidence. Still, if you face an issue in this tutorial then feel free to write us at

Additionally, explore our other blogs for a more step-by-step tutorial. Also, request you to write your feedback and follow us on Facebook and LinkedIn.