Selenium and TestNG Setup With Maven

Why we need Maven?

Maven is the best dependency management tool, a project created by Maven is easy to manage transport. Selenium is widely browser automation tool while TestNG is the best testing framework which provides an enormous number of methods to assert actual result with the expected result. In other words, Selenium and TestNG with maven is the most popular combination in Industries. 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, we guide you to do complete Selenium and TestNG set up and also write first selenium test. This tutorial explained each step with a clear snapshot which helps you to do this set up independently.


  1. 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 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


How to install or setup Selenium?

Steps to install Selenium:

  • Step 1: Go to Desktop and click on Eclipse icon to open eclipse
Open Eclipse IDE
  • Step 2: Select workspace: Eclipse is already set up then it will open with default workspace but if you are opening the first time then it will ask for workspace. Then you have to give one folder path as workspace.
Eclipse launcher
  • Step 3: Create Selenium Project (similar to Maven Project): Go to File> New and click on Project
Create Java Project
  • Step 4: Select a Wizard: To create Maven Project click on “Maven Project” and then click on Next
Maven project
  • Step 5: Click on “Next” on “New Maven Project” window
  • Step 6: Select Archetype – maven-archetype-quickstart and click on Next
Select Archetype for maven project
  • Step 7: Specify project archetype parameters and click on Finish. Now your automation project created with Maven.
Maven archetype parameters
  • Step 8: Click on Project and open POM.xml
  • Step 9: Add Selenium, TestNG, and WebDriverManager Maven Dependencies

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

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

<!-- -->

TestNG Dependency: (To be added in POM.XML)

<!-- -->

WebDriver Manager Dependency: (To be added in POM.XML) – WebDriverManager is used 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 depencies 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>
  • Step 10: Right-click on Project, go to Maven and click on “Update Project”.
Maven Update Project
  • Step 11: 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
  • Step 12: Create 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
  • Step 13: 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:

  • Step 14: 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 Selenium and TestNG Project created with Maven. And also you successfully write one test, executed and TestNg Report generated.

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

Explore our other blogs for more step by step tutorial. Also request you to write your feedback.


Subscribe to our Newsletter:

Open chat
Feel free to contact