Testcontainers Selenium 如何更新浏览器?

Testcontainers Selenium how to update browser?

我将 Testcontainers (1.14.1) 与 Selenium (4.0.0-alpha-5) 和 Chrome 用于 运行 我的 Java 集成测试。

但是当我 运行 我的测试时,我的 Angular 前端没有呈现。正如我发现的那样,这是因为容器内的 Chrome 版本太旧了。 Chrome 的版本是 43。 因此,为了修复我的测试,我必须更新 Chrome。

但是如何呢?

解决方法:使用最新稳定的Selenium版本!就我而言 3.141.59

我是如何找到解决方案的:

据我所知,Selenium 的当前 Chrome 版本为 Docker Tags

所以问题必须出在测试容器方面。我搜索了他们如何知道要使用哪个容器标签并找到了这个:

    /**
     * Based on the JARs detected on the classpath, determine which version of selenium-api is available.
     * @return the detected version of Selenium API, or DEFAULT_SELENIUM_VERSION if it could not be determined
     */
    public static String determineClasspathSeleniumVersion() {

Whole source at GitHub

我查看了我的 Selenium API jar,清单中没有 Selenium-Version 问题。 Selenium 的 4.0.0-alpha-5 没有容器标签。所以我只是降级到最后一个稳定版本的 Selenium。