{"record":{"id":"dbda31a3b45dbfb7","repo":"testcontainers/testcontainers-java","slug":"multiple-versions-of-selenium-api-found-on-classpath-will","errorCode":null,"errorMessage":"Multiple versions of Selenium API found on classpath - will select {}, but this may not be reliable","messagePattern":"Multiple versions of Selenium API found on classpath - will select (.+?), but this may not be reliable","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"modules/selenium/src/main/java/org/testcontainers/containers/SeleniumUtils.java","lineNumber":62,"sourceCode":"                        LOGGER.info(\"Selenium API version {} detected on classpath\", seleniumVersion);\n                    }\n                }\n            }\n        } catch (Exception e) {\n            LOGGER.debug(\"Failed to determine Selenium-Version from selenium-api JAR Manifest\", e);\n        }\n\n        if (seleniumVersions.size() == 0) {\n            LOGGER.warn(\n                \"Failed to determine Selenium version from classpath - will use default version of {}\",\n                DEFAULT_SELENIUM_VERSION\n            );\n            return DEFAULT_SELENIUM_VERSION;\n        }\n\n        String foundVersion = seleniumVersions.iterator().next();\n        if (seleniumVersions.size() > 1) {\n            LOGGER.warn(\n                \"Multiple versions of Selenium API found on classpath - will select {}, but this may not be reliable\",\n                foundVersion\n            );\n        }\n\n        return foundVersion;\n    }\n\n    /**\n     * Read Manifest to get Selenium Version.\n     * @param manifest manifest\n     * @return Selenium Version detected\n     */\n    public static String getSeleniumVersionFromManifest(Manifest manifest) {\n        String seleniumVersion = null;\n        Attributes buildInfo = manifest.getAttributes(\"Build-Info\");\n        if (buildInfo != null) {\n            seleniumVersion = buildInfo.getValue(\"Selenium-Version\");","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/selenium/src/main/java/org/testcontainers/containers/SeleniumUtils.java#L44-L80","documentation":"SeleniumUtils.determineClasspathSeleniumVersion logs this warning when more than one Selenium API version is detected on the classpath. It picks an arbitrary version (iterator().next()) to select the Docker image, which may not match the Selenium version the tests actually use. This can lead to protocol mismatches between the WebDriver client and the containerized Selenium.","triggerScenarios":"Having multiple selenium-api jars of different versions on the classpath (e.g. selenium-api 3.x pulled transitively alongside 4.x) and calling determineClasspathSeleniumVersion().","commonSituations":"Legacy Selenium 3 dependencies leaking in via transitive deps; multiple test frameworks (Selenide, Serenity) bundling different Selenium versions; dependency conflicts unresolved in Gradle/Maven.","solutions":["Run 'mvn dependency:tree' or 'gradle dependencies' to find duplicate selenium-api versions and exclude the transitive one.","Align all Selenium dependencies to a single version via dependencyManagement / a BOM.","Pin the Selenium Docker image explicitly so the ambiguous detection result does not matter."],"exampleFix":"// before\n// multiple selenium-api versions on classpath (3.141.59 via old dep, 4.10.0 direct)\n// after\n<dependency>\n  <groupId>org.seleniumhq.selenium</groupId>\n  <artifactId>selenium-api</artifactId>\n  <version>4.10.0</version>\n</dependency>\n<!-- plus exclusions on transitive selenium deps -->","handlingStrategy":"validation","validationCode":"Set<String> versions = seleniumVersionsOnClasspath(); // scan selenium-api jar manifests\nif (versions.size() > 1) {\n    throw new IllegalStateException(\"Multiple Selenium versions on classpath: \" + versions);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run dependency:tree / gradle dependencies to detect duplicate selenium-api versions","Exclude transitive Selenium 3 deps from legacy libraries","Use a Selenium BOM to align versions; pin the Docker image explicitly"],"tags":["selenium","classpath","dependency-conflict"],"backgroundTag":"conflicting-config-options","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}