Video summary
Session 52: Selenium with Java | Hybrid Framework | Grouping Tests, Extent Reports
Main summary
Key takeaways
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)
- Login verify →
- Tests can belong to multiple groups, e.g.:
"sanity, master"and"regression, master"
Meaning of master:
- If
masteris 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.
- Prevents overwriting by using a dynamic filename like
- 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).
- Tester name from
- Listener-driven report logging
onTestStart/onTestSuccesscreates per-test entries using class name as the test identifier (not method name).onTestSuccesslogs pass status.onTestFailurelogs failure + the error message.onTestSkippedlogs skip status + reason.
5) Screenshot capture on failures
- A
captureScreenmethod is added to the Base Class. - On
onTestFailure, the listener:- Calls
captureScreen(testName) - Saves the screenshot with a timestamp to avoid filename collisions
- Attaches the screenshot to the Extent report using
test.addScreenCaptureFromPath(...)
- Calls
- 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 usingextent.flush(). - Optional automation includes:
- Auto-opening the generated
extent-report.htmlin the browser - Optional email sending (Apache Commons Email / Gmail-specific configuration; noted as potentially limited/blocking)
- Auto-opening the generated
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
BaseClassinstance. - If
driveris notstatic, driver conflicts may occur (two different drivers).
Solution:
- Make the
driverreference 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.xmlundertest-output. - This XML includes only tests that failed in the previous run.
- After a run, TestNG generates
Notes:
- Passed tests entries may remain until TestNG refreshes the failure list on later runs.
- When new failures occur,
testng-failed.xmlupdates 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.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.