{"record":{"id":"4915695a4e118026","repo":"karatelabs/karate","slug":"webdriver-request-failed-request-method-request-uri-e","errorCode":null,"errorMessage":"WebDriver request failed: \" + request.method() + \" \" + request.uri() + \": \" + e.getMessage()","messagePattern":"WebDriver request failed: \" \\+ request\\.method\\(\\) \\+ \" \" \\+ request\\.uri\\(\\) \\+ \": \" \\+ e\\.getMessage\\(\\)","errorType":"exception","errorClass":"DriverException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/driver/w3c/W3cSession.java","lineNumber":465,"sourceCode":"                    Map<String, Object> errorMap = (Map<String, Object>) value;\n                    message = (String) errorMap.getOrDefault(\"message\", message);\n                    String error = (String) errorMap.get(\"error\");\n                    if (error != null) {\n                        message = error + \": \" + message;\n                    }\n                }\n                throw new DriverException(\"WebDriver \" + request.method() + \" \"\n                        + request.uri().getPath() + \" failed (\" + response.statusCode() + \"): \" + message);\n            }\n\n            return result;\n        } catch (DriverException e) {\n            throw e;\n        } catch (IOException | InterruptedException e) {\n            if (e instanceof InterruptedException) {\n                Thread.currentThread().interrupt();\n            }\n            throw new DriverException(\"WebDriver request failed: \" + request.method() + \" \"\n                    + request.uri() + \": \" + e.getMessage(), e);\n        }\n    }\n\n    private static Object getValue(Map<String, Object> response) {\n        return response.get(\"value\");\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private static String extractElementId(Map<String, Object> elementMap) {\n        String id = (String) elementMap.get(W3C_ELEMENT_KEY);\n        if (id == null) {\n            // Fallback for legacy servers\n            id = (String) elementMap.get(\"ELEMENT\");\n        }\n        if (id == null) {\n            throw new DriverException(\"WebDriver response missing element ID: \" + elementMap);\n        }","sourceCodeStart":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/driver/w3c/W3cSession.java#L447-L483","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nsession.get(url); // stale session after driver crash\n// after\nif (!session.isAlive()) { session = new W3cSession(options); }\nsession.get(url);","handlingStrategy":"retry","validationCode":"// probe the driver endpoint before issuing commands\ntry (var s = new java.net.Socket()) {\n    s.connect(new java.net.InetSocketAddress(host, port), 2000); // throws if driver dead\n}","typeGuard":null,"tryCatchPattern":"try {\n    return session.get(path);\n} catch (DriverException e) {\n    if (e.getCause() instanceof java.io.IOException) {\n        // transport failure: restart driver/session and retry once\n        session = restartSession(options);\n        return session.get(path);\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["webdriver","network","io-exception","connection"],"backgroundTag":"network-request-failed","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}