testcontainers/testcontainers-java · warning

Failed to determine Selenium version from classpath - will…

Error message

Failed to determine Selenium version from classpath - will use default version of {}

What it means

SeleniumUtils.determineClasspathSeleniumVersion logs this warning when it cannot detect the Selenium API version from the classpath JAR manifests and falls back to DEFAULT_SELENIUM_VERSION. The detected version picks the matching Selenium Docker image; a wrong default may mismatch the Selenium version your tests compile against. This is a warning only; a default version is returned.

Solutions

  1. Ensure the standard selenium-api dependency is a direct, non-shaded test dependency so its JAR manifest is readable.
  2. Pin the image explicitly via SeleniumUtils / withRecordingFileFactory alternatives or set the desired Docker image instead of relying on detection.
  3. Un-shadow or keep manifests in the shaded jar (keep 'META-INF/MANIFEST.MF' and selenium manifest attributes).

Example fix

// before
dockerImageName.parse("selenium/standalone-chrome:" + SeleniumUtils.determineClasspathSeleniumVersion()); // falls back silently
// after
dockerImageName.parse("selenium/standalone-chrome:4.10.0"); // pinned explicitly
Defensive patterns

Strategy: fallback

Validate before calling

// ensure selenium-api is a direct dependency
Class.forName("org.openqa.selenium.remote.RemoteWebDriver");

Prevention

When it happens

Trigger: Running tests where the selenium-api jar (or its Manifest with Selenium-Version attribute) is absent or unreadable, e.g. shaded/fat jars, relocated selenium-api, or a classpath without selenium-api.

Common situations: Shadowed test jars stripping manifests; exotic build setups (Gradle shadow plugin, ProGuard); dockerized test runners with trimmed classpaths; non-Maven dependency layouts.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of testcontainers/testcontainers-java@8e549514e3 (2026-09-12). Data as JSON: /api/errors/4bdbdf5decc85c9f. Report an issue: GitHub.

Appendix: source

Thrown at modules/selenium/src/main/java/org/testcontainers/containers/SeleniumUtils.java:53

            while (manifests.hasMoreElements()) {
                URL manifestURL = manifests.nextElement();
                try (InputStream is = manifestURL.openStream()) {
                    Manifest manifest = new Manifest();
                    manifest.read(is);

                    String seleniumVersion = getSeleniumVersionFromManifest(manifest);
                    if (seleniumVersion != null) {
                        seleniumVersions.add(seleniumVersion);
                        LOGGER.info("Selenium API version {} detected on classpath", seleniumVersion);
                    }
                }
            }
        } catch (Exception e) {
            LOGGER.debug("Failed to determine Selenium-Version from selenium-api JAR Manifest", e);
        }

        if (seleniumVersions.size() == 0) {
            LOGGER.warn(
                "Failed to determine Selenium version from classpath - will use default version of {}",
                DEFAULT_SELENIUM_VERSION
            );
            return DEFAULT_SELENIUM_VERSION;
        }

        String foundVersion = seleniumVersions.iterator().next();
        if (seleniumVersions.size() > 1) {
            LOGGER.warn(
                "Multiple versions of Selenium API found on classpath - will select {}, but this may not be reliable",
                foundVersion
            );
        }

        return foundVersion;
    }

    /**

View on GitHub (pinned to 8e549514e3)