selenium testng setup tutorial

Selenium Testng Setup Tutorial

What is TestNG Framework & How to Setup or Install TestNG Selenium Framework?

TestNG is a testing framework inspired by JUnit & NUnit with many additional features hence making it even more powerful & can help in designing a more robust automation testing framework.

Generally, TestNG covers all categories of tests:  unit, functional, end-to-end, integration, etc…

And, In this TestNG tutorial of ThoughtCoders you will learn “How to install and setup TestNG Selenium Framework” using Java? For this purpose, on the whole, we are providing you with step by step process and with a sample TestNG Selenium Framework.


  1. Firstly, install Java
  2. Any IDE like – Eclipse, IntelliJ IDEA, etc.
  3. Setup Selenium on System
  4. Download Browser driver (like- chrome driver, gecko driver, etc. )

Tutorial on Selenium Installation & Setup: Click Here

Steps to Install and Setup TestNG Selenium Framework:

Install TestNG jar files from “mvnrepository”

  • Click on testng 6.14.3 version and download jar file
download jar file
another image

Now, Create Java project & add Selenium, TestNG dependency or jar file

  • Open an IDE (Recommended – IntelliJ) & Create a Java Project
Create java project
  • After, setting up Java project, Project structure look like this
Java project structure
  • Right click on project folder and click on “Open Module Settings” option
open module settings
  • Go to Module -> “Dependencies” tab -> Click on “+” icon -> Click on Jars or directories
Add Jars or directories in IntelliJ IDE

Note: Enlarge or Zoom above image to see steps to add Jar file

  • Browse & Select testng jar file and Click on “Ok” button
testng-6.14.3 jar file
Selenium 3.141.59 version zip download
Selenium API jar files dependencies

Add Selenium with TestNG Project Structure after Selenium and TestNG Jar dependencies:

Selenium with TestNG project structure
  • Right click on “src” folder -> Click on New -> “Java class” -> Create Java class file (SampleTest)
Create java class file
SampleTest Java file

Coding our First Test Case

Let’s create our first Test Case that will check if ThoughtCoder’s Blog page is correct. Refer to the code below.

import org.openqa.selenium.*;
import org.testng.Assert;
import org.testng.annotations.*;

public class SampleTest {
    public String baseUrl = "";
    public WebDriver driver;

    //Using @Test testng annotation
    public void verifyBlog(){
        System.out.println("Launching Browser");

        driver = new ChromeDriver();
SampleTest Java file code & TestNG report window

On the positive side, hope, this tutorial eith the result that helped in installation, setup of Selenium with TestNG automation framework, and above SampleTest code clearly to illustrate that how we use TestNG annotation with Selenium to enable extraordinary features & reporting.

Summing up, we will continue exploring other Selenium with TestNG topics. To that end, subscribe to our newsletter to stay updated with our next blog.

Write A Comment