{"record":{"id":"c96abe16da322bc3","repo":"karatelabs/karate","slug":"inputfile-not-supported-by-this-driver","errorCode":null,"errorMessage":"inputFile not supported by this driver","messagePattern":"inputFile not supported by this driver","errorType":"exception","errorClass":"DriverException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/driver/Driver.java","lineNumber":939,"sourceCode":"    /**\n     * Set the files of a file {@code <input>} element — the ONLY way to drive a file upload:\n     * browsers forbid setting a file input's {@code value} from script (a page must never be\n     * able to pick a file off the user's disk), so {@code value()} throws and {@code input()}\n     * keystrokes go nowhere. Each backend uses its native mechanism instead (CDP\n     * {@code DOM.setFileInputFiles}, W3C element send-keys).\n     *\n     * <p>File references resolve exactly like {@code read()} — relative to the calling feature,\n     * with {@code classpath:}, a root-anchored leading {@code /}, and {@code file:} for a real\n     * OS path (see {@link DriverApi#resolveFilePaths}). Multiple files need an input with the\n     * {@code multiple} attribute. The element does not need to be visible — file inputs are\n     * routinely hidden behind styled buttons.</p>\n     *\n     * <p>NOTE: the resolved path is handed to the browser process — with a remote browser\n     * (grid, container) the file must exist on the machine the BROWSER runs on; use\n     * {@code file:} to name such a path verbatim.</p>\n     */\n    default Element inputFile(String locator, String... files) {\n        throw new DriverException(\"inputFile not supported by this driver\");\n    }\n\n    /**\n     * Set the value of an input element directly.\n     */\n    default Element value(String locator, String value) {\n        script(Locators.inputJs(locator, value));\n        return BaseElement.of(this, locator);\n    }\n\n    /**\n     * Select an option from a dropdown by text or value.\n     */\n    default Element select(String locator, String text) {\n        Object matched = script(Locators.optionSelector(locator, text));\n        if (!Boolean.TRUE.equals(matched)) {\n            throw new DriverException(\"select failed, no option matching: '\" + text + \"' for: \" + locator);\n        }","sourceCodeStart":921,"sourceCodeEnd":957,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/driver/Driver.java#L921-L957","documentation":"Driver.inputFile(String, String...) is a default method that drivers must override to support file uploads. The default implementation throws this DriverException, meaning the active driver (e.g. a minimal or custom Driver implementation) does not implement file upload. Note the resolved path must exist on the machine the browser runs on, not the machine running Karate.","triggerScenarios":"Calling driver.inputFile(\"input[type=file]\", \"data/file.pdf\") against a Driver implementation that did not override inputFile (custom driver, stub driver, or a driver type without upload support).","commonSituations":"Custom/third-party Driver implementations missing the override; drivers for environments where file transfer to the browser is impossible; outdated driver adapters lagging behind the current Karate API.","solutions":["Upgrade or fix the driver implementation so it overrides inputFile (re-check the adapter version matches your Karate version)","If using a remote browser, ensure the file path exists on the browser machine and pass it verbatim with the file: prefix","As a workaround, set the input value directly (driver.value(locator, path)) where the driver/browser supports it"],"exampleFix":"// before\ncustomDriver.inputFile(\"#upload\", \"/tmp/report.pdf\"); // throws\n// after\n// use a driver that overrides inputFile, e.g. Chrome/Edge/Gecko driver\ndriver.inputFile(\"#upload\", \"file:///tmp/report.pdf\");","handlingStrategy":"try-catch","validationCode":"// detect support before calling:\n// if (!(driver instanceof Chrome || driver instanceof Edge)) { /* use alternative */ }","typeGuard":null,"tryCatchPattern":"try { driver.inputFile(loc, path); } catch (DriverException e) { if (e.getMessage().equals(\"inputFile not supported by this driver\")) { /* fallback: value() or switch driver */ } else throw e; }","preventionTips":["Use a mainstream driver (Chrome/Edge/Gecko) that implements inputFile","For remote grids, ensure files exist on the browser host and pass file: URLs","Keep driver adapters at the same version as karate-core"],"tags":["ui","driver","file-upload","unsupported-operation"],"backgroundTag":"method-not-implemented","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"}