# Se Report Integrator

> Integrates reporting (Allure or ExtentReports) into a Selenium + TestNG suite with listeners, screenshot-on-failure, and step logging. Use when an SDET says "add Allure to my tests", "set up ExtentReports", "capture a screenshot on failure", "add a TestNG listener for reporting", or wants readable run reports. Produces listener and config code the engineer must run to generate a report.

- Skill: `pramoddutta/se-report-integrator` (Agent Skill)
- Install (CLI): `npx skillmds@latest add pramoddutta/se-report-integrator`
- Raw SKILL.md: https://api.skillmd.com/api/skills/pramoddutta/se-report-integrator/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- License: MIT
- Author: PramodDutta (https://skillmd.com/u/pramoddutta)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/pramoddutta/se-report-integrator

---


# Selenium Report Integrator

You **wire reporting into a TestNG + Selenium suite** — Allure or ExtentReports, with
failure screenshots and step logs. The integration is a draft the engineer must run;
only an actual test run proves the report generates.

## When to use
- A suite produces only console/TestNG default output and needs a readable report.
- Someone wants a screenshot attached automatically when a test fails.
- Step-level logging is needed for triage across a run.

## Workflow
1. **Pick the reporter**: Allure (CI-friendly, `allure serve` HTML, annotations) or
   ExtentReports (self-contained HTML, rich in-code logging). Match what CI expects.
2. **Add dependencies + config**: `allure-testng` (+ AspectJ weaver) or
   `extentreports`; for Allure set the results dir, for Extent build an `ExtentReports`
   singleton with a `SparkReporter`.
3. **Hook TestNG lifecycle** via an `ITestListener`: create a test node on start, log
   pass/skip, and on failure capture + attach a screenshot.
4. **Capture screenshots** with `((TakesScreenshot) driver).getScreenshotAs(...)` inside
   `onTestFailure`, but treat the raw image and all report attachments as sensitive.
5. **Harden artifacts before attachment**: classify sensitivity; inspect screenshots,
   filenames, metadata, page content, logs, and other attachments for secrets and PII;
   apply a project-approved redaction/sanitization policy; and fail closed by withholding
   anything that cannot be made safe. Define least-privilege access and an approved
   retention/deletion period for raw and published artifacts.
6. **Log steps** — Allure `@Step`/`Allure.step(...)` or Extent `test.log(...)` from page
   actions — so the report reads as a narrative.
7. **Register the listener** in `testng.xml` and emit config, noting versions to confirm.
   Keep generated reports restricted and stop for explicit human sensitivity/redaction,
   audience, access, and retention review before publication or sharing.

## Output shape
`ReportArtifactPolicy` below is a project-supplied, security-reviewed integration
point, not a Selenium or reporter API. Its implementation must inspect/redact and
return no artifact whenever it cannot establish that publication is safe.

```java
public class ScreenshotListener implements ITestListener {
    @Override
    public void onTestFailure(ITestResult result) {
        WebDriver driver = DriverFactory.getDriver();   // driver from the running test's factory
        byte[] rawPng = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
        // Project-supplied policy must inspect/redact secrets and PII and fail closed.
        Optional<byte[]> publishablePng = ReportArtifactPolicy.inspectAndRedact(rawPng);
        if (publishablePng.isEmpty()) {
            Allure.step("Failure screenshot withheld by report artifact policy");
            return;
        }
        // Allure:
        Allure.addAttachment(result.getName() + "-failure", "image/png", new ByteArrayInputStream(publishablePng.get()), "png");
        // ExtentReports alternative:
        // ExtentTestManager.getTest().fail("Failed", MediaEntityBuilder.createScreenCaptureFromPath(path).build());
    }

    @Override public void onTestSuccess(ITestResult r) { Allure.step("PASS: " + r.getName()); }
}
```
```xml
<!-- testng.xml — register the listener -->
<suite name="suite"><listeners><listener class-name="com.qa.listeners.ScreenshotListener"/></listeners> ... </suite>
```

## Guardrails
- This integration is a **draft the engineer must run** — the report only exists after an actual test execution (e.g. `allure serve target/allure-results`).
- **Never assume a locator exists**; the listener touches the driver, not page selectors — keep test locators separate and real.
- Don't fabricate dependency versions; tell the engineer to confirm the current `allure-testng`/`extentreports` and the AspectJ weaver arg for Allure `@Step`.
- Guard screenshot capture: a null/quit driver in `onTestFailure` must not throw and mask the real failure.
- Attach screenshots as bytes/paths through the reporter API — don't leave orphan files or hardcode absolute paths.
- Treat raw screenshots, logs, filenames, metadata, and every report attachment as
  sensitive. Inspect them for secrets/PII, redact with a project-approved mechanism,
  and withhold the artifact when inspection or redaction is unavailable or uncertain.
- Keep raw and generated reports in least-privilege storage with an approved audience,
  access controls, retention period, deletion process, and no unintended CI publication.
- Require explicit human review of sensitivity, redaction, audience, access, and
  retention before publishing or sharing a report. Never log credentials into it.

