karatelabs/karate · error · RuntimeException
driver keyword requires a URL argument
Error message
driver keyword requires a URL argument
What it means
The standalone `driver` keyword sets the browser driver's URL and requires the step text to be a non-empty expression evaluating to the server URL. When the text is null or blank there is nothing to evaluate or navigate to, so the executor throws immediately before evaluation.
Solutions
- Provide a URL: `driver 'http://localhost:9222'` or `driver myUrlVariable`
- If configuring instead of navigating, use `configure driver = {...}`
- Ensure the URL expression is on the same step text, not a docstring
- print the URL variable to confirm it is populated
Example fix
// before * driver // after * driver 'http://localhost:9222'
Defensive patterns
Strategy: validation
Validate before calling
* if (!driverUrl) karate.fail('driver step needs a URL') Prevention
- Never write a bare 'driver' step
- Keep driver URLs in config/environment files
- Review UI test templates for unfilled placeholders
When it happens
Trigger: A `driver` step with no text (e.g. `* driver` alone); text consisting only of whitespace; a step parsed such that the URL ended up in a docstring or argument instead of the text.
Common situations: Deleting the URL during refactoring; template placeholders like `driver <url>` left unfilled; formatting errors where the URL landed on a following line treated as a separate step.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- driver URL evaluated to null:
- element not found:
- missing array argument 'patterns':
- missing 'mock' or 'handler' in intercept config
- unknown window operation
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/302f784f351f1e9d.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/core/StepExecutor.java:3082
// Bare variable / JS expression: return the live object so mutations made
// after the configure step are reflected. Any embedded #(...) it carries is
// left intact and resolved per-request on a fresh copy.
return runtime.eval(wrapJsonLikeExpression(expr));
}
// ========== Browser Driver ==========
/**
* Execute the driver keyword - navigate to a URL.
* Examples:
* - driver 'http://localhost:8080'
* - driver serverUrl + '/path'
* - driver myUrl
*/
private void executeDriver(Step step) {
String text = step.getText();
if (text == null || text.trim().isEmpty()) {
throw new RuntimeException("driver keyword requires a URL argument");
}
// Evaluate the expression to get the URL
Object result = runtime.eval(text.trim());
if (result == null) {
throw new RuntimeException("driver URL evaluated to null: " + text);
}
String url = result.toString();
// Get the driver (initializes lazily if needed)
io.karatelabs.driver.Driver driver = runtime.getDriver();
// Navigate to the URL
driver.setUrl(url);
}
// ========== Karate Expression Helpers ==========View on GitHub (pinned to a22eb90246)