karatelabs/karate · warning
screenshotOnFailure: capture failed, continuing
Error message
screenshotOnFailure: capture failed, continuing: {} What it means
When `screenshotOnFailure` is enabled, Karate attempts a failure screenshot via the driver after a step fails. If any Throwable occurs during capture, it is logged as this warning and the scenario continues; the failure result itself is unaffected.
Solutions
- Treat as secondary symptom: first diagnose why the step failed and why the driver is unhealthy
- Check driver/browser logs for a crash or session termination
- Disable screenshotOnFailure if capture noise obscures the real failure
- Reconnect/restart the driver infrastructure (grid node, container)
Example fix
// before configure screenshotOnFailure = true // after (suppress noisy captures in unstable environments) configure screenshotOnFailure = karate.env != 'ci-smoke'
Defensive patterns
Strategy: try-catch
Try / catch
// Karate already catches internally; on your side guard any post-failure driver use:
try { var bytes = driver.failureScreenshot(); } catch (t) { karate.log('screenshot skipped', t); } Prevention
- Keep the browser session healthy (reasonable timeouts, avoid killing processes)
- Skip screenshotOnFailure in environments with flaky drivers
- Diagnose the primary step failure first; this warning is secondary
When it happens
Trigger: A step failed and Karate calls `driver.failureScreenshot()`, which throws (driver crashed, session already dead, WebSocket/CDP connection broken).
Common situations: Browser terminated before the failure screenshot; driver process OOM-killed; remote grid session expired mid-scenario; Driver wrapper in a bad state after a hard failure.
Related errors
- configure driver = } — bypassing driver pool; browser will…
- driver.stop=false — leaving browser running, scenario will…
- Error closing driver
- Error releasing driver to provider
- append() needs at least two arguments
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/09c5fa481cb3cad7.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/core/ScenarioRuntime.java:2005
* map first, falling back to the driver instance's frozen options. This
* lets per-scenario overrides take effect under pooled-driver reuse, where
* the driver instance's options reflect creation-time config not the
* current scenario's.
*/
private void captureScreenshotOnFailure(StepResult sr) {
if (driver == null || driver.isTerminated()) {
return;
}
try {
if (!isScreenshotOnFailureEnabled()) {
return;
}
byte[] bytes = driver.failureScreenshot();
if (bytes != null && bytes.length > 0) {
sr.addEmbed(new StepResult.Embed(bytes, "image/png", "screenshot.png"));
}
} catch (Throwable t) {
logger.warn("screenshotOnFailure: capture failed, continuing: {}", t.toString());
}
}
@SuppressWarnings("rawtypes")
private boolean isScreenshotOnFailureEnabled() {
Object cfg = config.getDriverConfig();
if (cfg instanceof Map map && map.containsKey("screenshotOnFailure")) {
Object v = map.get("screenshotOnFailure");
return v == null || Boolean.parseBoolean(String.valueOf(v));
}
try {
return driver.getOptions().isScreenshotOnFailure();
} catch (Exception e) {
return true;
}
}
/**View on GitHub (pinned to a22eb90246)