diff --git a/docs/examples/junit4/generic/build.gradle b/docs/examples/junit4/generic/build.gradle index da4697a4543..9388d754040 100644 --- a/docs/examples/junit4/generic/build.gradle +++ b/docs/examples/junit4/generic/build.gradle @@ -7,6 +7,6 @@ dependencies { testImplementation project(":mysql") testImplementation 'mysql:mysql-connector-java:8.0.21' - testImplementation "org.seleniumhq.selenium:selenium-api:3.141.59" + testImplementation 'org.seleniumhq.selenium:selenium-java:4.1.1' testImplementation 'org.assertj:assertj-core:3.15.0' } diff --git a/docs/examples/junit4/generic/src/test/java/generic/HostPortExposedTest.java b/docs/examples/junit4/generic/src/test/java/generic/HostPortExposedTest.java index 1d15c2553b8..2b2372bb6cb 100644 --- a/docs/examples/junit4/generic/src/test/java/generic/HostPortExposedTest.java +++ b/docs/examples/junit4/generic/src/test/java/generic/HostPortExposedTest.java @@ -9,9 +9,11 @@ import org.openqa.selenium.remote.RemoteWebDriver; import org.testcontainers.Testcontainers; import org.testcontainers.containers.BrowserWebDriverContainer; +import org.testcontainers.utility.DockerImageName; import java.io.OutputStream; import java.net.InetSocketAddress; +import java.net.URL; import static org.junit.Assert.assertTrue; @@ -46,7 +48,7 @@ public static void tearDown() throws Exception { } @Rule - public BrowserWebDriverContainer browser = new BrowserWebDriverContainer() + public BrowserWebDriverContainer browser = new BrowserWebDriverContainer<>("selenium/standalone-chrome:4") .withCapabilities(new ChromeOptions()); @Test @@ -55,7 +57,8 @@ public void testContainerRunningAgainstExposedHostPort() { final String rootUrl = String.format("http://host.testcontainers.internal:%d/", localServerPort); - final RemoteWebDriver webDriver = browser.getWebDriver(); + URL seleniumAddress = browser.getSeleniumAddress(); + RemoteWebDriver webDriver = new RemoteWebDriver(seleniumAddress, new ChromeOptions()); webDriver.get(rootUrl); // } diff --git a/docs/modules/webdriver_containers.md b/docs/modules/webdriver_containers.md index 34d3430830c..e28db414615 100644 --- a/docs/modules/webdriver_containers.md +++ b/docs/modules/webdriver_containers.md @@ -5,14 +5,12 @@ from SeleniumHQ's [docker-selenium](https://github.com/SeleniumHQ/docker-seleniu ## Benefits -* Fully compatible with Selenium 2/Webdriver tests, by providing a `RemoteWebDriver` instance +* Fully compatible with Selenium 3 & 4 tests, by providing a `RemoteWebDriver` instance * No need to have specific web browsers, or even a desktop environment, installed on test servers. The only dependency is a working Docker installation and your Java JUnit test suite. * Browsers are always launched from a fixed, clean image. This means no configuration drift from user changes or automatic browser upgrades. -* Compatibility between browser version and the Selenium API is assured: a compatible version of the browser docker - images will be automatically selected to match the version of `selenium-api-*.jar` on the classpath -* Additionally the use of a clean browser prevents leakage of cookies, cached data or other state between tests. +* Additionally, the use of a clean browser prevents leakage of cookies, cached data or other state between tests. * **VNC screen recording**: Testcontainers can automatically record video of test runs (optionally capturing just failing tests) @@ -80,10 +78,6 @@ If you would like to customise the file name of the recording, or provide a diff Note the factory must implement `org.testcontainers.containers.RecordingFileFactory`. -## More examples - -A few different examples are shown in [ChromeWebDriverContainerTest.java](https://github.com/testcontainers/testcontainers-java/blob/master/modules/selenium/src/test/java/org/testcontainers/junit/ChromeWebDriverContainerTest.java). - ## Adding this module to your project dependencies Add the following dependency to your `pom.xml`/`build.gradle` file: @@ -102,18 +96,17 @@ testImplementation "org.testcontainers:selenium:{{latest_version}}" ``` !!! hint - Adding this Testcontainers library JAR will not automatically add a Selenium Webdriver JAR to your project. You should ensure that your project also has suitable Selenium dependencies in place, for example: + Adding this Testcontainers library JAR will not automatically add a Selenium Webdriver JAR to your project. + You should ensure that your project also has suitable Selenium dependencies in place, for example: ```groovy tab='Gradle' - compile "org.seleniumhq.selenium:selenium-remote-driver:3.141.59" + implementation 'org.seleniumhq.selenium:selenium-java:4.1.1' ``` ```xml tab='Maven' org.seleniumhq.selenium - selenium-remote-driver - 3.141.59 + selenium-java + 4.1.1 ``` - - Testcontainers will try and match the version of the Dockerized browser to whichever version of Selenium is found on the classpath diff --git a/examples/cucumber/build.gradle b/examples/cucumber/build.gradle index edb62670134..0e2e24f5587 100644 --- a/examples/cucumber/build.gradle +++ b/examples/cucumber/build.gradle @@ -7,9 +7,7 @@ repositories { } dependencies { - implementation 'org.seleniumhq.selenium:selenium-remote-driver:3.141.59' - implementation 'org.seleniumhq.selenium:selenium-firefox-driver:3.141.59' - implementation 'org.seleniumhq.selenium:selenium-chrome-driver:3.141.59' + testImplementation 'org.seleniumhq.selenium:selenium-java:4.1.1' testImplementation 'io.cucumber:cucumber-java:7.1.0' testImplementation 'io.cucumber:cucumber-junit:7.1.0' testImplementation 'org.testcontainers:selenium' diff --git a/examples/cucumber/src/test/java/org/testcontainsers/examples/Stepdefs.java b/examples/cucumber/src/test/java/org/testcontainsers/examples/Stepdefs.java index ca70173ae92..ec26a2f5ff6 100644 --- a/examples/cucumber/src/test/java/org/testcontainsers/examples/Stepdefs.java +++ b/examples/cucumber/src/test/java/org/testcontainsers/examples/Stepdefs.java @@ -6,6 +6,7 @@ import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; +import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.remote.RemoteWebDriver; @@ -21,7 +22,7 @@ public class Stepdefs { - private BrowserWebDriverContainer container = new BrowserWebDriverContainer() + private final BrowserWebDriverContainer container = new BrowserWebDriverContainer<>("selenium/standalone-chrome:4") .withCapabilities(new ChromeOptions()) .withRecordingMode(RECORD_ALL, new File("build")); @@ -49,20 +50,20 @@ public String getFilesystemFriendlyName() { } @Given("^location is \"([^\"]*)\"$") - public void locationIs(String location) throws Exception { + public void locationIs(String location) { this.location = location; } @When("^I ask is it possible to search here$") - public void iAskIsItPossibleToSearchHere() throws Exception { - RemoteWebDriver driver = container.getWebDriver(); + public void iAskIsItPossibleToSearchHere() { + RemoteWebDriver driver = new RemoteWebDriver(container.getSeleniumAddress(), new ChromeOptions()); driver.get(location); - List searchInputs = driver.findElementsByTagName("input"); + List searchInputs = driver.findElements(By.tagName("input")); answer = searchInputs != null && searchInputs.size() > 0 ? "YES" : "NOPE"; } @Then("^I should be told \"([^\"]*)\"$") - public void iShouldBeTold(String expected) throws Exception { + public void iShouldBeTold(String expected) { assertEquals(expected, answer); } diff --git a/modules/selenium/build.gradle b/modules/selenium/build.gradle index 5f0824f8b12..eda91466ac5 100644 --- a/modules/selenium/build.gradle +++ b/modules/selenium/build.gradle @@ -3,11 +3,9 @@ description = "Testcontainers :: Selenium" dependencies { api project(':testcontainers') - provided 'org.seleniumhq.selenium:selenium-remote-driver:3.141.59' - provided 'org.seleniumhq.selenium:selenium-chrome-driver:3.141.59' - testImplementation 'org.seleniumhq.selenium:selenium-firefox-driver:3.141.59' - testImplementation 'org.seleniumhq.selenium:selenium-support:3.141.59' + implementation 'org.seleniumhq.selenium:selenium-chrome-driver:4.1.0' + testImplementation 'org.seleniumhq.selenium:selenium-firefox-driver:4.1.0' testImplementation 'org.mortbay.jetty:jetty:6.1.26' testImplementation project(':nginx') testImplementation 'org.rnorth.visible-assertions:visible-assertions:2.1.2' diff --git a/modules/selenium/src/main/java/org/testcontainers/containers/BrowserWebDriverContainer.java b/modules/selenium/src/main/java/org/testcontainers/containers/BrowserWebDriverContainer.java index 7bc37e4701c..cd2a459a037 100644 --- a/modules/selenium/src/main/java/org/testcontainers/containers/BrowserWebDriverContainer.java +++ b/modules/selenium/src/main/java/org/testcontainers/containers/BrowserWebDriverContainer.java @@ -1,26 +1,14 @@ package org.testcontainers.containers; -import static java.time.temporal.ChronoUnit.SECONDS; - import com.github.dockerjava.api.command.InspectContainerResponse; import com.github.dockerjava.api.model.AccessMode; import com.github.dockerjava.api.model.Bind; import com.github.dockerjava.api.model.Volume; import com.google.common.collect.ImmutableSet; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.file.Files; -import java.time.Duration; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.TimeUnit; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.openqa.selenium.Capabilities; import org.openqa.selenium.chrome.ChromeOptions; -import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.rnorth.ducttape.timeouts.Timeouts; @@ -35,8 +23,21 @@ import org.testcontainers.containers.wait.strategy.WaitStrategy; import org.testcontainers.lifecycle.TestDescription; import org.testcontainers.lifecycle.TestLifecycleAware; +import org.testcontainers.utility.ComparableVersion; import org.testcontainers.utility.DockerImageName; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.file.Files; +import java.time.Duration; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import static java.time.temporal.ChronoUnit.SECONDS; + /** * A chrome/firefox/custom container based on SeleniumHQ's standalone container sets. *

@@ -44,13 +45,15 @@ */ public class BrowserWebDriverContainer> extends GenericContainer implements LinkableContainer, TestLifecycleAware { - private static final DockerImageName CHROME_IMAGE = DockerImageName.parse("selenium/standalone-chrome-debug"); - private static final DockerImageName FIREFOX_IMAGE = DockerImageName.parse("selenium/standalone-firefox-debug"); + private static final DockerImageName CHROME_IMAGE = DockerImageName.parse("selenium/standalone-chrome"); + private static final DockerImageName FIREFOX_IMAGE = DockerImageName.parse("selenium/standalone-firefox"); + private static final DockerImageName CHROME_DEBUG_IMAGE = DockerImageName.parse("selenium/standalone-chrome-debug"); + private static final DockerImageName FIREFOX_DEBUG_IMAGE = DockerImageName.parse("selenium/standalone-firefox-debug"); private static final DockerImageName[] COMPATIBLE_IMAGES = new DockerImageName[] { + CHROME_DEBUG_IMAGE, + FIREFOX_DEBUG_IMAGE, CHROME_IMAGE, - FIREFOX_IMAGE, - DockerImageName.parse("selenium/standalone-chrome"), - DockerImageName.parse("selenium/standalone-firefox") + FIREFOX_IMAGE }; private static final String DEFAULT_PASSWORD = "secret"; @@ -75,6 +78,10 @@ public class BrowserWebDriverContainer getLivenessCheckPorts() { @Override protected void configure() { - String seleniumVersion = SeleniumUtils.determineClasspathSeleniumVersion(); - if (capabilities == null) { - if (seleniumVersion.startsWith("2.")) { - logger().info("No capabilities provided, falling back to DesiredCapabilities.chrome()"); - capabilities = DesiredCapabilities.chrome(); - } else { - logger().info("No capabilities provided, falling back to ChromeOptions"); - capabilities = new ChromeOptions(); - } - } - - // Hack for new selenium-chrome image that contains Chrome 92. - // If not disabled, container startup will fail in most cases and consume excessive amounts of CPU. - if (capabilities instanceof ChromeOptions) { - ChromeOptions options = (ChromeOptions) this.capabilities; - options.addArguments("--disable-gpu"); - } - if (recordingMode != VncRecordingMode.SKIP) { if (vncRecordingDirectory == null) { @@ -200,6 +198,13 @@ protected void configure() { super.setDockerImageName(customImageName.asCanonicalNameString()); } else { DockerImageName standardImageForCapabilities = getStandardImageForCapabilities(capabilities, seleniumVersion); + logger().warn( + "Image name for selenium image has not been set, and one will be inferred automatically based " + + "on capabilities ({}). Inferred image: {}. This feature is deprecated and will be removed " + + "in the future.", + standardImageForCapabilities.asCanonicalNameString(), + this.capabilities + ); super.setDockerImageName(standardImageForCapabilities.asCanonicalNameString()); } @@ -233,10 +238,7 @@ protected void configure() { * @param seleniumVersion the version of selenium in use * @return an image name for the default standalone Docker image for the appropriate browser * - * @deprecated note that this method is deprecated and may be removed in the future. The no-args - * {@link BrowserWebDriverContainer#BrowserWebDriverContainer()} combined with the - * {@link BrowserWebDriverContainer#withCapabilities(Capabilities)} method should be considered. A decision on - * removal of this deprecated method will be taken at a future date. + * @deprecated note that this method is deprecated and will be removed in the future. */ @Deprecated public static String getDockerImageForCapabilities(Capabilities capabilities, String seleniumVersion) { @@ -244,23 +246,38 @@ public static String getDockerImageForCapabilities(Capabilities capabilities, St } private static DockerImageName getStandardImageForCapabilities(Capabilities capabilities, String seleniumVersion) { - String browserName = capabilities.getBrowserName(); - switch (browserName) { - case BrowserType.CHROME: - return CHROME_IMAGE.withTag(seleniumVersion); - case BrowserType.FIREFOX: - return FIREFOX_IMAGE.withTag(seleniumVersion); - default: - throw new UnsupportedOperationException("Browser name must be 'chrome' or 'firefox'; provided '" + browserName + "' is not supported"); + boolean supportsVncWithoutDebugImage = new ComparableVersion(seleniumVersion).isGreaterThanOrEqualTo("4"); + + String browserName; + if (capabilities == null) { + // opinionated default for deprecated path + browserName = "chrome"; + } else { + browserName = capabilities.getBrowserName(); } + + if (browserName.equals("chrome")) { + if (supportsVncWithoutDebugImage) { + return CHROME_IMAGE; + } else { + return CHROME_DEBUG_IMAGE; + } + } else if (browserName.equals("firefox")) { + if (supportsVncWithoutDebugImage) { + return FIREFOX_IMAGE; + } else { + return FIREFOX_DEBUG_IMAGE; + } + } + + throw new UnsupportedOperationException("Browser name must be 'chrome' or 'firefox'; 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; + throw new RuntimeException("Failed to construct a valid URL!", e); } } @@ -280,10 +297,6 @@ public int getPort() { @Override protected void containerIsStarted(InspectContainerResponse containerInfo) { - driver = Unreliables.retryUntilSuccess(30, TimeUnit.SECONDS, - () -> Timeouts.getWithTimeout(10, TimeUnit.SECONDS, - () -> new RemoteWebDriver(getSeleniumAddress(), capabilities))); - if (vncRecordingContainer != null) { LOGGER.debug("Starting VNC recording"); vncRecordingContainer.start(); @@ -296,9 +309,25 @@ protected void containerIsStarted(InspectContainerResponse containerInfo) { * All containers and drivers will be automatically shut down after the test method finishes (if used as a @Rule) or the test * class (if used as a @ClassRule) * + * @deprecated please use {@link BrowserWebDriverContainer#getSeleniumAddress()} to obtain the selenium server URL, + * and call the {@link RemoteWebDriver} constructor ({@link RemoteWebDriver#RemoteWebDriver(URL, Capabilities)}), + * passing in the URL and {@link Capabilities} object instead. + * * @return a new Remote Web Driver instance */ - public RemoteWebDriver getWebDriver() { + @Deprecated + public synchronized RemoteWebDriver getWebDriver() { + if (driver == null) { + if (capabilities == null) { + logger().warn("No capabilities provided - this will cause an exception in future versions. Falling back to ChromeOptions"); + capabilities = new ChromeOptions(); + } + + driver = Unreliables.retryUntilSuccess(30, TimeUnit.SECONDS, + () -> Timeouts.getWithTimeout(10, TimeUnit.SECONDS, + () -> new RemoteWebDriver(getSeleniumAddress(), capabilities))); + } + return driver; } diff --git a/modules/selenium/src/test/java/org/testcontainers/junit/BrowserWebDriverContainerTest.java b/modules/selenium/src/test/java/org/testcontainers/junit/BrowserWebDriverContainerTest.java index 7b7d3a46733..240b046f980 100644 --- a/modules/selenium/src/test/java/org/testcontainers/junit/BrowserWebDriverContainerTest.java +++ b/modules/selenium/src/test/java/org/testcontainers/junit/BrowserWebDriverContainerTest.java @@ -19,11 +19,13 @@ public class BrowserWebDriverContainerTest { private static final String NO_PROXY_VALUE = "localhost,.noproxy-domain.com"; + private static final String CHROME_IMAGE = "selenium/standalone-chrome:4.1.1"; + private static final String FIREFOX_IMAGE = "selenium/standalone-firefox:4.1.1"; + @Test public void honorPresetNoProxyEnvironment() { try ( - BrowserWebDriverContainer chromeWithNoProxySet = (BrowserWebDriverContainer) new BrowserWebDriverContainer() - .withCapabilities(new ChromeOptions()) + BrowserWebDriverContainer chromeWithNoProxySet = new BrowserWebDriverContainer<>(CHROME_IMAGE) .withEnv(NO_PROXY_KEY, NO_PROXY_VALUE) ) { chromeWithNoProxySet.start(); @@ -36,9 +38,7 @@ public void honorPresetNoProxyEnvironment() { @Test public void provideDefaultNoProxyEnvironmentIfNotSet() { try ( - BrowserWebDriverContainer chromeWithoutNoProxySet = new BrowserWebDriverContainer() - .withCapabilities(new ChromeOptions()) - + BrowserWebDriverContainer chromeWithoutNoProxySet = new BrowserWebDriverContainer<>(CHROME_IMAGE) ) { chromeWithoutNoProxySet.start(); @@ -51,8 +51,7 @@ public void provideDefaultNoProxyEnvironmentIfNotSet() { @Test public void createContainerWithShmVolume() { try ( - BrowserWebDriverContainer webDriverContainer = new BrowserWebDriverContainer() - .withCapabilities(new FirefoxOptions()) + BrowserWebDriverContainer webDriverContainer = new BrowserWebDriverContainer<>(FIREFOX_IMAGE) ) { webDriverContainer.start(); @@ -67,9 +66,8 @@ public void createContainerWithShmVolume() { @Test public void createContainerWithoutShmVolume() { try ( - BrowserWebDriverContainer webDriverContainer = new BrowserWebDriverContainer<>() + BrowserWebDriverContainer webDriverContainer = new BrowserWebDriverContainer<>(FIREFOX_IMAGE) .withSharedMemorySize(512 * FileUtils.ONE_MB) - .withCapabilities(new FirefoxOptions()) ) { webDriverContainer.start(); @@ -81,7 +79,7 @@ public void createContainerWithoutShmVolume() { } } - private List shmVolumes(final BrowserWebDriverContainer container) { + private List shmVolumes(final BrowserWebDriverContainer container) { return container.getContainerInfo().getMounts() .stream() // destination path is always /dev/shm diff --git a/modules/selenium/src/test/java/org/testcontainers/junit/ChromeRecordingWebDriverContainerTest.java b/modules/selenium/src/test/java/org/testcontainers/junit/ChromeRecordingWebDriverContainerTest.java index fdf56aa0134..123ade32b7f 100644 --- a/modules/selenium/src/test/java/org/testcontainers/junit/ChromeRecordingWebDriverContainerTest.java +++ b/modules/selenium/src/test/java/org/testcontainers/junit/ChromeRecordingWebDriverContainerTest.java @@ -50,8 +50,7 @@ public void recordingTestThatShouldBeRecordedAndRetainedInFlvFormatAsDefault() t try ( // recordAll { // To do this, simply add extra parameters to the rule constructor, so video will default to FLV format: - BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>() - .withCapabilities(new ChromeOptions()) + BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>("selenium/standalone-chrome:4.1.1") .withRecordingMode(RECORD_ALL, target) // } .withRecordingFileFactory(new DefaultRecordingFileFactory()) @@ -88,8 +87,7 @@ public void recordingTestShouldHaveFlvExtension() throws InterruptedException { try ( // recordFlv { // Set (explicitly) FLV format for recorded video: - BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>() - .withCapabilities(new ChromeOptions()) + BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>("selenium/standalone-chrome:4.1.1") .withRecordingMode(RECORD_ALL, target, VncRecordingFormat.FLV) // } .withRecordingFileFactory(new DefaultRecordingFileFactory()) @@ -106,8 +104,7 @@ public void recordingTestShouldHaveMp4Extension() throws InterruptedException { try ( // recordMp4 { // Set MP4 format for recorded video: - BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>() - .withCapabilities(new ChromeOptions()) + BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>("selenium/standalone-chrome:4.1.1") .withRecordingMode(RECORD_ALL, target, VncRecordingFormat.MP4) // } .withRecordingFileFactory(new DefaultRecordingFileFactory()) @@ -122,8 +119,7 @@ public void recordingTestShouldHaveMp4Extension() throws InterruptedException { public void recordingTestThatShouldHaveCorrectDuration() throws IOException, InterruptedException { MountableFile mountableFile; try ( - BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>() - .withCapabilities(new ChromeOptions()) + BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>("selenium/standalone-chrome:4.1.1") .withRecordingMode(RECORD_ALL, vncRecordingDirectory.getRoot()) .withRecordingFileFactory(new DefaultRecordingFileFactory()) .withNetwork(NETWORK) @@ -158,9 +154,8 @@ public static class ChromeThatRecordsFailingTests { public void recordingTestThatShouldBeRecordedButNotPersisted() { try ( // withRecordingFileFactory { - BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>() + BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>("selenium/standalone-chrome:4.1.1") // } - .withCapabilities(new ChromeOptions()) // withRecordingFileFactory { .withRecordingFileFactory(new CustomRecordingFileFactory()) // } @@ -178,8 +173,7 @@ public void recordingTestThatShouldBeRecordedAndRetained() throws InterruptedExc try ( // recordFailing { // or if you only want videos for test failures: - BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>() - .withCapabilities(new ChromeOptions()) + BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>("selenium/standalone-chrome:4.1.1") .withRecordingMode(RECORD_FAILING, target) // } .withRecordingFileFactory(new DefaultRecordingFileFactory()) diff --git a/modules/selenium/src/test/java/org/testcontainers/junit/ChromeWebDriverContainerTest.java b/modules/selenium/src/test/java/org/testcontainers/junit/ChromeWebDriverContainerTest.java index bea1909a145..52c326bc710 100644 --- a/modules/selenium/src/test/java/org/testcontainers/junit/ChromeWebDriverContainerTest.java +++ b/modules/selenium/src/test/java/org/testcontainers/junit/ChromeWebDriverContainerTest.java @@ -13,8 +13,7 @@ public class ChromeWebDriverContainerTest extends BaseWebDriverContainerTest { // junitRule { @Rule - public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>() - .withCapabilities(new ChromeOptions()) + public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>("selenium/standalone-chrome:4.1.1") // } .withNetwork(NETWORK); diff --git a/modules/selenium/src/test/java/org/testcontainers/junit/ContainerWithoutCapabilitiesTest.java b/modules/selenium/src/test/java/org/testcontainers/junit/ContainerWithoutCapabilitiesTest.java index b1214d18b60..ec97cc7083c 100644 --- a/modules/selenium/src/test/java/org/testcontainers/junit/ContainerWithoutCapabilitiesTest.java +++ b/modules/selenium/src/test/java/org/testcontainers/junit/ContainerWithoutCapabilitiesTest.java @@ -7,7 +7,7 @@ public class ContainerWithoutCapabilitiesTest extends BaseWebDriverContainerTest{ @Rule - public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>() + public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>("selenium/standalone-chrome:4.1.1") .withNetwork(NETWORK); @Test diff --git a/modules/selenium/src/test/java/org/testcontainers/junit/CustomWaitTimeoutWebDriverContainerTest.java b/modules/selenium/src/test/java/org/testcontainers/junit/CustomWaitTimeoutWebDriverContainerTest.java index 8448dc40d53..5538ac15508 100644 --- a/modules/selenium/src/test/java/org/testcontainers/junit/CustomWaitTimeoutWebDriverContainerTest.java +++ b/modules/selenium/src/test/java/org/testcontainers/junit/CustomWaitTimeoutWebDriverContainerTest.java @@ -15,8 +15,7 @@ public class CustomWaitTimeoutWebDriverContainerTest extends BaseWebDriverContainerTest { @Rule - public BrowserWebDriverContainer chromeWithCustomTimeout = new BrowserWebDriverContainer<>() - .withCapabilities(new ChromeOptions()) + public BrowserWebDriverContainer chromeWithCustomTimeout = new BrowserWebDriverContainer<>("selenium/standalone-chrome:4.1.1") .withStartupTimeout(Duration.of(30, SECONDS)) .withNetwork(NETWORK); diff --git a/modules/selenium/src/test/java/org/testcontainers/junit/FirefoxWebDriverContainerTest.java b/modules/selenium/src/test/java/org/testcontainers/junit/FirefoxWebDriverContainerTest.java index 1cffec16bc6..5fbe6494060 100644 --- a/modules/selenium/src/test/java/org/testcontainers/junit/FirefoxWebDriverContainerTest.java +++ b/modules/selenium/src/test/java/org/testcontainers/junit/FirefoxWebDriverContainerTest.java @@ -13,8 +13,7 @@ public class FirefoxWebDriverContainerTest extends BaseWebDriverContainerTest { // junitRule { @Rule - public BrowserWebDriverContainer firefox = new BrowserWebDriverContainer<>() - .withCapabilities(new FirefoxOptions()) + public BrowserWebDriverContainer firefox = new BrowserWebDriverContainer<>("selenium/standalone-firefox:4.1.1") // } .withNetwork(NETWORK); diff --git a/modules/selenium/src/test/java/org/testcontainers/junit/LocalServerWebDriverContainerTest.java b/modules/selenium/src/test/java/org/testcontainers/junit/LocalServerWebDriverContainerTest.java index f7d626c15b5..b4763aaaef9 100644 --- a/modules/selenium/src/test/java/org/testcontainers/junit/LocalServerWebDriverContainerTest.java +++ b/modules/selenium/src/test/java/org/testcontainers/junit/LocalServerWebDriverContainerTest.java @@ -20,7 +20,7 @@ public class LocalServerWebDriverContainerTest { @Rule - public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer().withCapabilities(new ChromeOptions()); + public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer<>("selenium/standalone-chrome:4.1.1"); private int localPort; /** @@ -50,7 +50,7 @@ public void setupLocalServer() throws Exception { @Test public void testConnection() { // getWebDriver { - RemoteWebDriver driver = chrome.getWebDriver(); + RemoteWebDriver driver = new RemoteWebDriver(chrome.getSeleniumAddress(), new ChromeOptions()); // } // Construct a URL that the browser container can access diff --git a/modules/selenium/src/test/java/org/testcontainers/junit/SeleniumStartTest.java b/modules/selenium/src/test/java/org/testcontainers/junit/SeleniumStartTest.java index a236a9696c1..b920897d844 100644 --- a/modules/selenium/src/test/java/org/testcontainers/junit/SeleniumStartTest.java +++ b/modules/selenium/src/test/java/org/testcontainers/junit/SeleniumStartTest.java @@ -15,7 +15,7 @@ public class SeleniumStartTest { @Parameterized.Parameters(name = "tag: {0}") public static String[] data() { - return new String[]{"4.0.0", "3.4.0", "2.53.0", "2.45.0"}; + return new String[]{"4.0.0", "3.4.0"}; } @Parameterized.Parameter() diff --git a/modules/selenium/src/test/java/org/testcontainers/junit/SpecificImageNameWebDriverContainerTest.java b/modules/selenium/src/test/java/org/testcontainers/junit/SpecificImageNameWebDriverContainerTest.java deleted file mode 100644 index 9a15c6b466d..00000000000 --- a/modules/selenium/src/test/java/org/testcontainers/junit/SpecificImageNameWebDriverContainerTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.testcontainers.junit; - -import org.junit.Rule; -import org.junit.Test; -import org.openqa.selenium.firefox.FirefoxOptions; -import org.testcontainers.containers.BrowserWebDriverContainer; -import org.testcontainers.utility.DockerImageName; - -public class SpecificImageNameWebDriverContainerTest extends BaseWebDriverContainerTest { - - private static final DockerImageName FIREFOX_IMAGE = DockerImageName - .parse("selenium/standalone-firefox:2.53.1-beryllium"); - - @Rule - public BrowserWebDriverContainer firefox = new BrowserWebDriverContainer<>(FIREFOX_IMAGE) - .withCapabilities(new FirefoxOptions()) - .withNetwork(NETWORK); - - @Test - public void simpleExploreTest() { - doSimpleExplore(firefox); - } -}