0
0
Selenium Javatesting~10 mins

TestNG default reports in Selenium Java - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test opens a web page, clicks a button, and verifies the page title. It uses TestNG framework which generates default reports showing test pass or fail status.

Test Code - TestNG
Selenium Java
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class SampleTest {
    WebDriver driver;

    @BeforeClass
    public void setup() {
        driver = new ChromeDriver();
        driver.manage().window().maximize();
    }

    @Test
    public void testButtonClickChangesTitle() {
        driver.get("https://example.com");
        WebElement button = driver.findElement(By.id("changeTitleBtn"));
        button.click();
        String expectedTitle = "Title Changed";
        String actualTitle = driver.getTitle();
        Assert.assertEquals(actualTitle, expectedTitle, "Page title should change after button click");
    }

    @AfterClass
    public void teardown() {
        if (driver != null) {
            driver.quit();
        }
    }
}
Execution Trace - 9 Steps
StepActionSystem StateAssertionResult
1Test startsTestNG test suite initialized-PASS
2Browser opens ChromeDriver and maximizes windowChrome browser window is open and maximized-PASS
3Navigates to https://example.comExample.com homepage is loaded-PASS
4Finds button with id 'changeTitleBtn'Button element is located on the page-PASS
5Clicks the buttonPage title changes to 'Title Changed'-PASS
6Gets the page titlePage title is 'Title Changed'Assert that actual title equals 'Title Changed'PASS
7Test method completesTestNG records test as passed-PASS
8Browser quitsBrowser window closed-PASS
9TestNG generates default report showing test passedReport available in test-output folder with test status PASS-PASS
Failure Scenario
Failing Condition: Button with id 'changeTitleBtn' is not found or page title does not change as expected
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify after clicking the button?
AThe page title changes to 'Title Changed'
BThe button becomes disabled
CA new page opens in a new tab
DThe button text changes
Key Result
Always verify UI changes with assertions and rely on TestNG's default reports to quickly identify test pass or fail status.