Video summary

Session 52: Selenium with Java | Hybrid Framework | Grouping Tests, Extent Reports

Main summary

Key takeaways

Technology

Selenium + TestNG Framework Enhancements (Session 52) — Key Concepts & Implementation Notes

1) Grouping tests using TestNG groups

  • Each test method is tagged using @Test(groups = ...).
  • Examples from the session:
    • Login verify → groups = "sanity"
    • Account registration → groups = "regression"
    • Data-driven test → an additional group such as groups = "dataDriven" (kept separate from normal runs)
  • Tests can belong to multiple groups, e.g.:
    • "sanity, master" and "regression, master"

Meaning of master:

  • If master is included in execution, it means all tests (or all relevant tests under master) run.

2) Ensure @BeforeClass/@AfterClass/@BeforeSuite-type hooks run for selected groups

  • When execution is restricted using groups in testng.xml, setup/teardown methods must also be annotated with matching groups.
  • Otherwise, they won’t trigger under grouped execution.

3) Use a single grouping.xml to run different subsets (Include/Exclude)

  • A dedicated XML file (e.g., grouping.xml) controls which groups run.
  • Uses TestNG <groups> in XML:

Include examples:

  • <include name="sanity"/> → runs only sanity tests
  • <include name="regression"/> → runs only regression tests
  • Including master → runs all tests under master

Exclude for refinement:

  • If a test belongs to both sanity and regression, you can run:
    • sanity but not regression
  • Configuration:
    • <include name="sanity"/>
    • <exclude name="regression"/>

4) Extent Reports integration (ExtentReportManager utility)

This session adds richer reporting using a custom Extent Report Utility and a listener.

Key features:

  • Report name generation with timestamp
    • Prevents overwriting by using a dynamic filename like MyReport_<timestamp>.html.
  • Dynamic report header/environment details
    • Tester name from System.getProperty("user.name").
    • OS + browser name extracted from XML parameters using ITestContext / XmlTest.
    • The report shows the executed group(s).
  • Listener-driven report logging
    • onTestStart/onTestSuccess creates per-test entries using class name as the test identifier (not method name).
    • onTestSuccess logs pass status.
    • onTestFailure logs failure + the error message.
    • onTestSkipped logs skip status + reason.

5) Screenshot capture on failures

  • A captureScreen method is added to the Base Class.
  • On onTestFailure, the listener:
    1. Calls captureScreen(testName)
    2. Saves the screenshot with a timestamp to avoid filename collisions
    3. Attaches the screenshot to the Extent report using test.addScreenCaptureFromPath(...)
  • Screenshot attachment uses try-catch to handle issues (e.g., missing files).

6) Automatically open report and optionally email it

  • In onFinish, the listener flushes the Extent report using extent.flush().
  • Optional automation includes:
    • Auto-opening the generated extent-report.html in the browser
    • Optional email sending (Apache Commons Email / Gmail-specific configuration; noted as potentially limited/blocking)

7) Register the listener in testng.xml

Add the Extent listener in XML:

<listeners>
  <listener class-name="utilities.ExtentReportManager"/>
</listeners>
  • Applies to relevant XML files (including grouping.xml, and cross-browser XML if used).

8) Critical fix: make WebDriver static to avoid multiple driver instances

Framework issue explained:

  • The Extent listener creates a new BaseClass instance.
  • If driver is not static, driver conflicts may occur (two different drivers).

Solution:

  • Make the driver reference static so screenshot capture uses the same driver instance.

9) Run only previously failed tests using testng-failed.xml

  • TestNG’s built-in feature:
    • After a run, TestNG generates testng-failed.xml under test-output.
    • This XML includes only tests that failed in the previous run.

Notes:

  • Passed tests entries may remain until TestNG refreshes the failure list on later runs.
  • When new failures occur, testng-failed.xml updates to reflect the latest failing set.

Main speakers / sources (as stated in the subtitles)

  • Single main speaker/instructor (no named person detected in the subtitles).

Rate this summary

Your feedback will help improve summaries.

Improve this summary

Reprocess with a stronger model when the summary feels incomplete or inaccurate.

Pro

Translate summary in another language

Pro

Ask questions to this video

Chat for follow-up questions, clarifications, and source-backed answers.

Coming soon

Share this summary

Original video