karatelabs/karate · error · IllegalArgumentException

Unknown W3C driver type: " + type

Error message

Unknown W3C driver type: " + type

What it means

W3cDriverOptions validates the configured `type` against the known W3cBrowserType enum and throws IllegalArgumentException 'Unknown W3C driver type: <type>' when the value is not recognized. It is a configuration-time validation so bad driver types fail fast before any process is launched.

Solutions

  1. Set `type` to a supported value (e.g. 'chromedriver', 'geckodriver' — check W3cBrowserType.fromType for exact strings)
  2. Check spelling/case of the type string in the driver config map
  3. Upgrade Karate if the browser you need was added in a newer W3cBrowserType

Example fix

// before (karate-config.js)
karate.configure('driver', { type: 'chrome' }); // not a W3C driver type
// after
karate.configure('driver', { type: 'chromedriver' });
Defensive patterns

Strategy: validation

Validate before calling

Set<String> allowed = Set.of("chromedriver", "geckodriver");
if (!allowed.contains(type)) throw new IllegalArgumentException("Unknown W3C driver type: " + type);

Try / catch

try {
    options = new W3cDriverOptions(map);
} catch (IllegalArgumentException e) {
    // log supported types and fix config
}

Prevention

When it happens

Trigger: Constructing W3cDriverOptions from a map (driver config in karate-config.js or DriverOptions) with `type` set to a value not in W3cBrowserType, or with a misspelling/case mismatch like 'ChromeDriver' / 'firefox-driver'.

Common situations: Typo in karate-config.js `type` field; copying config from CDP-based Karate where type names differ; introducing a new browser type with an outdated Karate version that lacks it.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12). Data as JSON: /api/errors/932677d39086c8b3. Report an issue: GitHub.

Appendix: source

Thrown at karate-core/src/main/java/io/karatelabs/driver/w3c/W3cDriverOptions.java:71

    private final PageLoadStrategy pageLoadStrategy;
    private final String scope;
    private final boolean stop;

    // W3C-specific
    private final String webDriverUrl;
    private final Map<String, Object> webDriverSession;
    private final Map<String, Object> capabilities;
    private final boolean start;
    private final String executable;
    private final int port;
    private final List<String> addOptions;

    @SuppressWarnings("unchecked")
    private W3cDriverOptions(Map<String, Object> map) {
        String type = (String) map.getOrDefault("type", "chromedriver");
        this.browserType = W3cBrowserType.fromType(type);
        if (this.browserType == null) {
            throw new IllegalArgumentException("Unknown W3C driver type: " + type);
        }

        this.timeout = toInt(map.get("timeout"), 30000);
        this.retryCount = toInt(map.get("retryCount"), 3);
        this.retryInterval = toInt(map.get("retryInterval"), 500);
        this.headless = toBool(map.get("headless"), false);
        this.screenshotOnFailure = toBool(map.get("screenshotOnFailure"), true);
        this.highlight = toBool(map.get("highlight"), false);
        this.highlightDuration = toInt(map.get("highlightDuration"), 3000);
        this.pageLoadStrategy = PageLoadStrategy.DOMCONTENT_AND_FRAMES;
        this.scope = (String) map.getOrDefault("scope", "scenario");
        this.stop = toBool(map.get("stop"), true);

        this.webDriverUrl = (String) map.get("webDriverUrl");
        this.webDriverSession = (Map<String, Object>) map.get("webDriverSession");
        this.capabilities = (Map<String, Object>) map.get("capabilities");
        this.start = toBool(map.get("start"), true);
        this.executable = (String) map.get("executable");

View on GitHub (pinned to a22eb90246)