karatelabs/karate · error · DriverException
WebDriver request failed: " + request.method() + " " +…
Error message
WebDriver request failed: " + request.method() + " " + request.uri() + ": " + e.getMessage()
What it means
This DriverException wraps low-level transport failures (IOException or InterruptedException) that occur while sending a request to the WebDriver remote endpoint. Unlike error 270, the HTTP exchange itself failed — no valid WebDriver response was received — so the message includes the full request URI and the underlying exception message.
Solutions
- Verify the driver process is still running and its port is correct
- Check driver/server logs for a crash just before the request
- Increase the HTTP/read timeout if the command legitimately takes long
- Restart the browser session and retry the scenario
Example fix
// before
session.get(url); // stale session after driver crash
// after
if (!session.isAlive()) { session = new W3cSession(options); }
session.get(url); Defensive patterns
Strategy: retry
Validate before calling
// probe the driver endpoint before issuing commands
try (var s = new java.net.Socket()) {
s.connect(new java.net.InetSocketAddress(host, port), 2000); // throws if driver dead
} Try / catch
try {
return session.get(path);
} catch (DriverException e) {
if (e.getCause() instanceof java.io.IOException) {
// transport failure: restart driver/session and retry once
session = restartSession(options);
return session.get(path);
}
throw e;
} Prevention
- Monitor the driver process health between commands
- Set generous but bounded HTTP timeouts
- Log driver stdout/stderr to detect crashes early
- Use a session-factory that recreates sessions on transport errors
When it happens
Trigger: get(), postRaw() or delete() calls in W3cSession.execute() where the connection is refused, the driver process has died, the socket times out, or the thread is interrupted while awaiting the response. The thread-interrupt flag is re-set before throwing.
Common situations: Chromedriver/geckodriver crashed mid-session or was killed, wrong port configured for the driver endpoint, network firewall blocking localhost, or test-framework timeouts interrupting the HTTP call.
Related errors
- WebDriver session create failed: " + e.getMessage()
- Timeout waiting for WebDriver on
- Port : not available within timeout
- Failed to start
- javascript failed
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/4915695a4e118026.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/driver/w3c/W3cSession.java:465
Map<String, Object> errorMap = (Map<String, Object>) value;
message = (String) errorMap.getOrDefault("message", message);
String error = (String) errorMap.get("error");
if (error != null) {
message = error + ": " + message;
}
}
throw new DriverException("WebDriver " + request.method() + " "
+ request.uri().getPath() + " failed (" + response.statusCode() + "): " + message);
}
return result;
} catch (DriverException e) {
throw e;
} catch (IOException | InterruptedException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
throw new DriverException("WebDriver request failed: " + request.method() + " "
+ request.uri() + ": " + e.getMessage(), e);
}
}
private static Object getValue(Map<String, Object> response) {
return response.get("value");
}
@SuppressWarnings("unchecked")
private static String extractElementId(Map<String, Object> elementMap) {
String id = (String) elementMap.get(W3C_ELEMENT_KEY);
if (id == null) {
// Fallback for legacy servers
id = (String) elementMap.get("ELEMENT");
}
if (id == null) {
throw new DriverException("WebDriver response missing element ID: " + elementMap);
}View on GitHub (pinned to a22eb90246)