{"record":{"id":"30c2d26de96d4b5f","repo":"karatelabs/karate","slug":"driver-url-evaluated-to-null","errorCode":null,"errorMessage":"driver URL evaluated to null: ","messagePattern":"driver URL evaluated to null: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/StepExecutor.java","lineNumber":3088,"sourceCode":"    // ========== Browser Driver ==========\n\n    /**\n     * Execute the driver keyword - navigate to a URL.\n     * Examples:\n     * - driver 'http://localhost:8080'\n     * - driver serverUrl + '/path'\n     * - driver myUrl\n     */\n    private void executeDriver(Step step) {\n        String text = step.getText();\n        if (text == null || text.trim().isEmpty()) {\n            throw new RuntimeException(\"driver keyword requires a URL argument\");\n        }\n\n        // Evaluate the expression to get the URL\n        Object result = runtime.eval(text.trim());\n        if (result == null) {\n            throw new RuntimeException(\"driver URL evaluated to null: \" + text);\n        }\n\n        String url = result.toString();\n\n        // Get the driver (initializes lazily if needed)\n        io.karatelabs.driver.Driver driver = runtime.getDriver();\n\n        // Navigate to the URL\n        driver.setUrl(url);\n    }\n\n    // ========== Karate Expression Helpers ==========\n\n    /**\n     * Gets a response header value by name (case-insensitive).\n     * V1 compatibility: \"match header Content-Type contains '...'\"\n     * Returns the first value if header has multiple values, null if not found.\n     */","sourceCodeStart":3070,"sourceCodeEnd":3106,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/StepExecutor.java#L3070-L3106","documentation":"After the `driver` step text is evaluated as a Karate/JS expression, the result must be a usable URL. If evaluation returns null (undefined variable, expression with no value), the executor cannot derive a URL string and throws this error including the original text. It is distinct from the blank-text case: here there WAS an expression, it just produced null.","triggerScenarios":"`driver someVar` where someVar is undefined; an expression like `driver karate.properties('my.url')` where the system property is not set (evaluates to null); null-returning JS calls used as the URL.","commonSituations":"Missing environment/system properties in CI so karate.properties returns null; typos in variable names; assuming a previous configure step defines the URL variable when it does not.","solutions":["Define the variable first: `def url = 'http://localhost:9222'` before the driver step","Use a default: `driver karate.properties('my.url') || 'http://localhost:9222'`","print the expression result to verify it is non-null","Check the environment config file (karate.env) provides the expected property"],"exampleFix":"// before\n* driver karate.properties('driver.url')\n# after\n* def driverUrl = karate.properties('driver.url') || 'http://localhost:9222'\n* driver driverUrl","handlingStrategy":"validation","validationCode":"* def driverUrl = karate.properties('driver.url') || 'http://localhost:9222'\n* if (!driverUrl) karate.fail('driver URL not configured')","typeGuard":"function isNonEmptyString(v) { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":null,"preventionTips":["Provide defaults for properties used in driver steps","print URL expressions before driver steps in debug runs","Verify environment config supplies driver URLs in CI"],"tags":["driver","ui","null","url"],"backgroundTag":"null-argument","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"}