To display Selenium screenshots in an ExtentReports report produced by GitLab CI/CD, capture each image in the job workspace, attach its path to the matching Extent test, call extent.flush(), and upload both the report and image files as GitLab job artifacts. To see a screenshot directly in GitLab’s failed-test details as well, generate JUnit XML with GitLab’s screenshot attachment path and upload the image as an artifact; an Extent HTML report is a separate deliverable.
How the screenshot reaches the reader
There are three separate links in the workflow, and each must work:
- Selenium creates the image. Save the browser state to a file in the CI job workspace, preferably under a predictable screenshot directory.
- ExtentReports references the image. Add the saved path to the correct test or log entry. The report needs to be flushed after test activity so its output is written.
- GitLab retains the output. Upload the Extent report and the referenced images as job artifacts. If GitLab’s test details should link to an image, also produce JUnit XML using GitLab’s documented attachment convention.
A screenshot file existing on the runner is not enough: it must be referenced by the report, and the image and report must both survive as artifacts. The Extent HTML artifact and GitLab’s JUnit test-result interface are two distinct ways of presenting test output; they can be used together.
Capture and attach a Selenium screenshot in ExtentReports
The following Java outline uses Selenium’s TakesScreenshot API and ExtentReports’ Java v5 path-based media API. It assumes driver and extent have already been initialized for the test run. Configure reporter creation, imports, dependency versions, and test lifecycle for your project. The snippet is an integration pattern, not a tested project template.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
File image = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
Path saved = Paths.get("target", "screenshots", testName + ".png");
Files.createDirectories(saved.getParent());
Files.copy(image.toPath(), saved, StandardCopyOption.REPLACE_EXISTING);
ExtentTest test = extent.createTest(testName);
test.fail("Browser state at failure",
MediaEntityBuilder.createScreenCaptureFromPath(saved.toString()).build());
// In teardown after all tests and report logging:
extent.flush();
Use the attachment call at the point where you know which test the image belongs to. In this example, test.fail(...) records a failure log with the screenshot media. For a snapshot associated with a test or log, ExtentReports also provides addScreenCaptureFromPath(...); choose the method that fits how your report records media. The Java v5 API documents MediaEntityBuilder.createScreenCaptureFromPath(path).build() and path-based screenshot methods, and its path API can throw IOException if the image cannot be found. Handle or surface that exception instead of silently generating a report with a missing image.
Choose stable paths and unique names
- Keep screenshots under the project workspace, for example
target/screenshots/, so the job can upload them. - Use a filename that uniquely identifies the test when tests can run concurrently. A test name alone may collide if the same test runs more than once or parallel workers write simultaneously; add a run, worker, or unique test identifier when needed.
- Keep enough of the test or suite structure in the filename or directory layout to identify the corresponding case after download.
- Make sure the path passed to ExtentReports will still resolve when the HTML is opened. A path valid in the runner’s current directory may not be valid relative to the report file’s output directory.
ExtentReports documents path-based screenshot references, but the final path relationship depends on where your reporter writes the HTML and where you retain images. Preserve both and verify the references in the downloaded artifact rather than assuming the runner’s filesystem layout will match the reader’s.
Flush even when tests fail
ExtentReports v5 documents extent.flush() as writing or updating test information to the reporter destination. Put it in teardown or finalization that still runs after a failed assertion, after the relevant tests and logging have had a chance to finish. If the process exits before flushing, the report may be absent or incomplete. The placement in failure-safe teardown is an implementation recommendation; the documented behavior is that flush writes or updates report data.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Publish the Extent report and images as GitLab artifacts
Add the actual report directory and screenshot directory to artifacts:paths. GitLab documents this setting for browsing report output files. Use artifacts:when: always when you need diagnostic files retained after a failed job.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsselenium-tests:
stage: test
script:
- mvn test
artifacts:
when: always
paths:
- target/extent-report/
- target/screenshots/
- target/surefire-reports/TEST-*.xml
reports:
junit: target/surefire-reports/TEST-*.xml
This is illustrative GitLab CI YAML. Set target/extent-report/ to the destination configured for your Extent reporter, and change the JUnit path to match the test framework and build tool. The reports:junit entry tells GitLab where to find JUnit results; the separate artifacts:paths entries retain browseable/downloadable files, including the Extent report and screenshots. If the relevant paths are outside the job workspace or misspelled, GitLab cannot upload them as intended.
Where to open the HTML report
After the job completes, open its artifacts in GitLab and browse or download the report directory. The Extent report is a standalone HTML output, not a report GitLab converts into its native JUnit test-results view. Include image files alongside it so the HTML’s screenshot references can resolve after artifact download.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Show screenshots in GitLab failed-test details with JUnit XML
GitLab documents a JUnit XML attachment convention for linking a screenshot with a test case. Put the image path in the test case’s system-out using [[ATTACHMENT|path]], and upload the referenced image file. The path is relative to $CI_PROJECT_DIR, so the XML path and artifact location must agree.
<testcase time="1.00" name="Example test">
<system-out>[[ATTACHMENT|target/screenshots/example.png]]</system-out>
</testcase>
For the example to work, target/screenshots/example.png must be the screenshot’s location relative to the repository workspace and must be included in the uploaded artifacts. The attachment convention is separate from ExtentReports: keep attaching the image to the Extent test if you also want it in the Extent HTML report. JUnit producers differ, so ensure your framework emits the attachment text in the test case’s XML rather than assuming that writing an Extent report adds it automatically.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match| Presentation | Where it opens | Required setup | Useful for |
|---|---|---|---|
| ExtentReports HTML | GitLab job artifacts, browsed or downloaded | Attach media to Extent test/log, flush the report, and upload report plus images with artifacts:paths |
Extent’s report and test/log presentation |
| GitLab JUnit screenshot attachment | Screenshot link in GitLab failed-test details | JUnit XML attachment path relative to $CI_PROJECT_DIR, plus uploaded image file |
Opening failure evidence alongside a test result |
Verify the result after the job
- Check the job log for test completion and any screenshot-copy or report-writing errors.
- Confirm that the Extent report directory and screenshot directory appear in the job artifacts.
- Download or browse the Extent output and open a test that has a screenshot. Confirm the image loads rather than relying only on the existence of the PNG file.
- If using GitLab’s test details, open a failed case and check that its screenshot attachment is linked. Confirm the XML path is relative to
$CI_PROJECT_DIRand matches the uploaded image path.
Troubleshoot missing reports and screenshots
Extent report opens but the screenshot is broken
- Confirm the image exists before the Extent attachment method is called.
- Check the exact path passed to
createScreenCaptureFromPath(...)oraddScreenCaptureFromPath(...), and handle a missing-pathIOException. - Verify that the HTML’s reference is valid from the report’s output location and that the image is retained with the report.
- Check whether parallel tests overwrote a shared filename. Use unique per-test output paths.
Extent report is missing or incomplete after the job
- Call
extent.flush()after test entries and logging have been created. - Ensure the reporter destination is inside the job workspace and the same directory is included in
artifacts:paths. - Check that the configured destination matches the path you browse in GitLab; the example directory is not mandatory.
Files disappear when tests fail
Configure artifacts:when: always for the job artifacts if the report and screenshots should be uploaded after failure. Also ensure teardown still flushes ExtentReports after an assertion failure; artifact retention cannot restore report data that the test process never wrote.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Screenshot is absent from GitLab’s test details
Uploading an Extent HTML report does not by itself create GitLab’s documented JUnit screenshot link. Generate JUnit XML with the [[ATTACHMENT|...]] path inside the matching test case’s system-out, and upload the corresponding image. Check that the path is relative to $CI_PROJECT_DIR.
Screenshot works in the runner but breaks after download
The report may refer to a runner path or a location not preserved in artifacts. Retain the referenced image directory beside the report, then validate the HTML from the downloaded artifact. The relevant test is whether the saved report and image layout still agree, not whether the path existed during the job.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If the task is to capture a website rather than test an application’s browser state, ScreenshotNeo offers a screenshot API and MCP server. It does not replace Selenium’s in-test browser state or ExtentReports’ test logging; it is an alternative for capturing a URL directly.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
One GET request returns an image or PDF. For example, using cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Its clean-shot workflow removes known consent banners, newsletter popups, and chat widgets before capture, with each step configurable. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; responses identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Can GitLab display an ExtentReports HTML file in its JUnit test-results view?
No. GitLab’s failed-test screenshot links use JUnit XML attachment paths; the Extent HTML report remains a separate artifact.
Can I use ExtentReports and GitLab’s screenshot attachments together?
Yes. Attach the image to the Extent test and also include its path in the matching JUnit XML test case, then retain the image as an artifact.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

