testcontainers/testcontainers-java · error · UnsupportedOperationException

Browser name must be 'chrome', 'firefox' or…

Error message

Browser name must be 'chrome', 'firefox' or 'MicrosoftEdge';provided '${browserName}' is not supported

What it means

BrowserWebDriverContainer.getStandardImageForCapabilities only supports chrome, firefox and MicrosoftEdge browser types when selecting the standard selenium docker image. Any other browser name falls to the default switch branch and throws UnsupportedOperationException listing the supported browsers.

Solutions

  1. Use ChromeOptions, FirefoxOptions or EdgeOptions so the browser name is exactly 'chrome', 'firefox' or 'MicrosoftEdge'.
  2. Fix typos/casing: use 'MicrosoftEdge' not 'edge'/'Edge', 'chrome' not 'Chrome'.
  3. Remove unsupported browser types (Safari, IE, HtmlUnit) from testcontainers-based tests or run them outside testcontainers.
  4. Extend/override image selection yourself if you need another browser instead of relying on the standard mapping.

Example fix

// before
container.withCapabilities(new SafariOptions()); // unsupported
// after
container.withCapabilities(new ChromeOptions());
Defensive patterns

Strategy: validation

Validate before calling

static boolean isSupportedBrowser(String name) {
  return "chrome".equals(name) || "firefox".equals(name) || "MicrosoftEdge".equals(name);
}
// assert isSupportedBrowser(capabilities.getBrowserName());

Type guard

static boolean isSupportedBrowser(Capabilities caps) {
  String n = caps != null ? caps.getBrowserName() : null;
  return "chrome".equals(n) || "firefox".equals(n) || "MicrosoftEdge".equals(n);
}

Try / catch

try {
  String image = BrowserWebDriverContainer.standardImageForCapabilities(browserName, version);
} catch (UnsupportedOperationException e) {
  if (e.getMessage().contains("Browser name must be")) {
    throw new IllegalArgumentException("Use chrome/firefox/MicrosoftEdge, got: " + browserName); }
  throw e;
}

Prevention

When it happens

Trigger: Calling standardImageForCapabilities("safari"/"htmlunit"/arbitrary name, version) or getDockerImageForCapabilities with Capabilities whose getBrowserName() is not chrome/firefox/MicrosoftEdge.

Common situations: Passing Safari, InternetExplorer, Opera or HtmlUnit capabilities; typos like 'edge' or 'Chrome' (case-sensitive match against BrowserType constants).

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 testcontainers/testcontainers-java@8e549514e3 (2026-09-12). Data as JSON: /api/errors/d58a933c024f3e05. Report an issue: GitHub.

Appendix: source

Thrown at modules/selenium/src/main/java/org/testcontainers/containers/BrowserWebDriverContainer.java:270

        switch (browserName) {
            case BrowserType.CHROME:
                return (supportsVncWithoutDebugImage ? CHROME_IMAGE : CHROME_DEBUG_IMAGE).withTag(seleniumVersion);
            case BrowserType.FIREFOX:
                return (supportsVncWithoutDebugImage ? FIREFOX_IMAGE : FIREFOX_DEBUG_IMAGE).withTag(seleniumVersion);
            case BrowserType.EDGE:
                if (supportsVncWithoutDebugImage) {
                    return EDGE_IMAGE.withTag(seleniumVersion);
                }
                throw new UnsupportedOperationException(
                    "For browser 'MicrosoftEdge' selenium version must be 4 or higher;" +
                    "docker images are available from there upwards;" +
                    "provided version: '" +
                    seleniumVersion +
                    "'"
                );
            default:
                throw new UnsupportedOperationException(
                    "Browser name must be 'chrome', 'firefox' or 'MicrosoftEdge';" +
                    "provided '" +
                    browserName +
                    "' is not supported"
                );
        }
    }

    public URL getSeleniumAddress() {
        try {
            return new URL("http", getHost(), getMappedPort(SELENIUM_PORT), "/wd/hub");
        } catch (MalformedURLException e) {
            e.printStackTrace(); // TODO
            return null;
        }
    }

    public String getVncAddress() {

View on GitHub (pinned to 8e549514e3)