Yes. Selenide captures a screenshot automatically when a Selenide check fails. In the documented default Gradle setup, the image is written under build/reports/tests. You can change that directory, take a named screenshot at any point, return the image as bytes/base64/a temporary file, and collect HTML or MHTML page source alongside it.
This guide follows the current Selenide API documentation (Javadoc identified as 7.18.2 on 2026-09-29). The MHTML behavior described is specific to the Selenide 7.18.0 release note dated 2026-08-20.
Automatic screenshots when a test fails
Selenide’s screenshot guide says: “Yes, Selenide takes screenshots automatically on every test failure.” A failed Selenide condition therefore gives you visual evidence without adding a screenshot call to every test.
Where the file is written
The guide documents build/reports/tests as the default reports folder for Gradle projects. The exact artifact name is generated by Selenide and the surrounding test framework. Publishing that directory in CI is a separate build-server configuration step; Selenide does not automatically attach files to every CI report format.
Turn automatic capture off or on
The current Configuration.screenshots setting defaults to true. Set it in Java:
import com.codeborne.selenide.Configuration;
Configuration.screenshots = false;
Or pass the equivalent system property:
./gradlew test -Dselenide.screenshots=false
This switch controls automatic failure screenshots. It does not disable an explicit named call such as Selenide.screenshot("checkout").
Take a screenshot at a deliberate point
Use the static Selenide method when you need evidence before an assertion, after a state transition, or at a business milestone:
import static com.codeborne.selenide.Selenide.screenshot;
String pngFileName = screenshot("checkout_after_payment");
The argument is a base filename without an extension, and Selenide creates checkout_after_payment.png. The method returns the resulting filename. The PNG is created even when Configuration.screenshots = false, because that setting applies to automatic failure capture.
Recommended Free Tools
Complete JUnit 5 example
import org.junit.jupiter.api.Test;
import static com.codeborne.selenide.Condition.text;
import static com.codeborne.selenide.Selenide.*;
class CheckoutTest {
@Test
void recordsTheConfirmationPage() {
open("https://example.test/checkout");
$("[data-test=place-order]").click();
$("[data-test=confirmation]").shouldHave(text("Order confirmed"));
screenshot("checkout_confirmation");
}
}
Use a stable, unique base name when a test can run in parallel. Avoid putting secrets, tokens, or personal data into filenames or screenshots.
Choose the artifact folder
Set Configuration.reportsFolder in code:
Configuration.reportsFolder = "test-result/reports";
Or set it for a run:
./gradlew test -Dselenide.reportsFolder=test-result/reports
The path is interpreted by the test process. In CI, make the directory an uploaded artifact after tests finish; the correct upload syntax depends on your CI provider.
Rank #2
Capture page source with the image
The PNG and page source are separate artifacts. The source settings are independent of the screenshot switch.
| Need | Setting or API | Documented behavior |
|---|---|---|
| Save source | Configuration.savePageSource |
Current Javadoc lists true by default; ordinary source is HTML. |
| Include resources | Configuration.savePageSourceWithResources |
Current Javadoc lists false by default. Supported Chromium captures MHTML; otherwise Selenide falls back to HTML when capture is unavailable or fails. |
Configuration.savePageSource = true;
Configuration.savePageSourceWithResources = true;
Selenide 7.18.0 uses Chromium’s CDP Page.captureSnapshot for MHTML. The release note explicitly describes fallback to plain HTML if Chromium/CDP capture cannot be used. MHTML is therefore not a cross-browser guarantee.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesWhat the release example does—and does not—mean
The 2026-08-20 release post shows one example run containing a 12,042-byte HTML file, a 244,198-byte PNG, and a 190,104-byte MHTML file. Those are sample file sizes from that run, not performance benchmarks or expected sizes for your pages.
Return an image to your test code
When another API needs the image rather than a report filename, request an output type:
import org.openqa.selenium.OutputType;
import static com.codeborne.selenide.Selenide.screenshot;
byte[] png = screenshot(OutputType.BYTES);
String base64 = screenshot(OutputType.BASE64);
java.io.File temporaryPng = screenshot(OutputType.FILE);
The Selenide API documents these generic forms as returning bytes, Base64, or a file. It can return null when the WebDriver does not support screenshots. The FILE result is temporary and is not guaranteed to remain after tests complete, so copy it into your configured reports directory or another durable location if you need it later.
Copy a returned file to durable storage
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
var temporary = screenshot(OutputType.FILE);
if (temporary != null) {
Files.createDirectories(Path.of("test-result/reports"));
Files.copy(temporary.toPath(),
Path.of("test-result/reports", "checkout-returned.png"),
StandardCopyOption.REPLACE_EXISTING);
}
Element, page, and iframe captures
Selenide documents whole-page screenshot calls and screenshot methods on elements and iframe elements. Use an element capture when the useful evidence is a component such as a validation panel; use the static page call for the current browser view. The documented APIs do not promise full-page scrolling capture, nor do they promise MHTML outside the Chromium/CDP behavior described above.
Capture successful tests and non-Selenide failures
Automatic screenshots are aimed at Selenide check failures. If you also need images for successful tests or failures raised by a different assertion library, use the documented test-runner integrations.
JUnit 5
Selenide’s screenshot guide documents ScreenShooterExtension. Follow the extension setup in that guide for your Selenide and JUnit versions, then enable the mode appropriate to your run (for example, successful tests as well as failures). This keeps lifecycle handling in the extension instead of scattering calls through every test.
TestNG
The same guide documents a TestNG listener for test-wide screenshots. Register the listener using the setup shown there and keep the listener version aligned with your Selenide dependency.
Kotlin
The guide also includes a Kotlin extension example. The principle is identical: configure the documented extension for your runner, then let it capture at the lifecycle event you select. Do not assume a JUnit extension can be registered unchanged in TestNG.
Java and Kotlin configuration patterns
Java
import com.codeborne.selenide.Configuration;
Configuration.reportsFolder = "test-result/reports";
Configuration.screenshots = true;
Configuration.savePageSource = true;
Configuration.savePageSourceWithResources = false;
Kotlin
import com.codeborne.selenide.Configuration
Configuration.reportsFolder = "test-result/reports"
Configuration.screenshots = true
Configuration.savePageSource = true
Configuration.savePageSourceWithResources = false
System properties are useful when the same test binary runs locally and in CI:
./gradlew test
-Dselenide.reportsFolder=test-result/reports
-Dselenide.screenshots=true
Remote browsers and CI artifact handling
Selenide’s FAQ lists Selenoid, Moon, BrowserStack, LambdaTest, TestMu AI, TestContainers, and other cloud-provider contexts as compatible use cases. Compatibility does not by itself configure artifact retention. For remote runs, verify that the test JVM’s reports directory is copied from the worker to durable CI storage before the worker is destroyed. Also check whether your provider offers a separate session screenshot; that is an additional provider feature, not a replacement for Selenide’s files.
Rank #4
Common problems and fixes
No image after a failure
- Check
Configuration.screenshotsand theselenide.screenshotssystem property; a false value disables automatic capture. - Inspect the configured
reportsFolder, not only the default directory. - Ensure the CI job uploads the directory after tests and that the worker has write permission.
- If the driver does not support screenshots, the output-type API can return
null.
The named screenshot is missing
Use the static Selenide.screenshot("name") call and pass a base name without an extension. Remember that the method writes to the reports location and that a parallel test may overwrite an identical name.
HTML exists but resources are absent
Set Configuration.savePageSourceWithResources = true and use a supported Chromium driver. If CDP snapshot capture is unavailable or fails, Selenide’s documented fallback is plain HTML.
Outdated 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 matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallThe returned temporary file disappears
OutputType.FILE is temporary by design. Copy it immediately to a durable directory, as shown earlier, instead of relying on the temporary path after the test process exits.
Failure screenshots contain sensitive information
Review pages, cookies, authorization headers, and test data before publishing artifacts. Restrict CI artifact access and use test accounts with non-production data; Selenide does not redact the browser viewport for you.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If your goal is a URL screenshot outside a Java test session, ScreenshotNeo provides a single-call website screenshot API. It accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled. Only clean shots are billed: bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and each response reports the result through X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
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 documentation for authentication and options. The service supports PNG, JPEG, WebP, and PDF, plus element selectors, dark mode, device presets, retina scale, custom CSS/JavaScript, click-before-capture, waits, request blocking, custom headers/cookies/user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage reporting, and an OpenAPI specification. Parameter names used by other screenshot APIs also work for easier migration.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The Free plan includes 1,000 shots per month without a card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free. Create a free ScreenshotNeo account to try it.
Best Value
Which Selenide method should you use?
| Requirement | Recommended approach |
|---|---|
| Evidence only when a Selenide check fails | Leave Configuration.screenshots enabled. |
| Capture a known test milestone | Selenide.screenshot("name"). |
| Send image data to another API | screenshot(OutputType.BYTES) or BASE64. |
| Keep a returned file | OutputType.FILE, then copy it immediately. |
| Capture successful tests or non-Selenide assertions | Use the documented JUnit 5 extension or TestNG listener. |
| Need source for diagnosis | Enable savePageSource; request resource-inclusive MHTML only for supported Chromium/CDP runs. |
Frequently asked questions
Can Selenide take screenshots?
Yes. It captures screenshots automatically on test failure by default, and you can request one explicitly with Selenide.screenshot("name").
Can I take screenshot without enabling automatic screenshots?
Yes. A named screenshot call still creates its PNG when Configuration.screenshots is false.
Can I tell Selenide to put screenshots to a specific folder?
Yes. Set Configuration.reportsFolder or pass -Dselenide.reportsFolder=....
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Does Selenide always produce MHTML?
No. Resource-inclusive capture depends on Chromium/CDP support and falls back to HTML when that capture is unavailable or unsuccessful.
Are Selenide screenshots automatically attached to my CI report?
Not necessarily. Selenide writes artifacts; your build or CI configuration must publish the reports directory.
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.

