Class BrowserWebDriverContainer<SELF extends BrowserWebDriverContainer<SELF>>

java.lang.Object
org.testcontainers.containers.FailureDetectingExternalResource
org.testcontainers.containers.GenericContainer<SELF>
org.testcontainers.containers.BrowserWebDriverContainer<SELF>
All Implemented Interfaces:
AutoCloseable, org.junit.rules.TestRule, org.testcontainers.containers.Container<SELF>, org.testcontainers.containers.ContainerState, org.testcontainers.containers.traits.LinkableContainer, org.testcontainers.containers.wait.strategy.WaitStrategyTarget, org.testcontainers.lifecycle.Startable, org.testcontainers.lifecycle.TestLifecycleAware

public class BrowserWebDriverContainer<SELF extends BrowserWebDriverContainer<SELF>> extends org.testcontainers.containers.GenericContainer<SELF> implements org.testcontainers.containers.traits.LinkableContainer, org.testcontainers.lifecycle.TestLifecycleAware
A chrome/firefox/custom container based on SeleniumHQ's standalone container sets.

Supported images: selenium/standalone-chrome, selenium/standalone-firefox, selenium/standalone-edge, selenium/standalone-chrome-debug, selenium/standalone-firefox-debug

Exposed ports: 4444

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     

    Nested classes/interfaces inherited from interface org.testcontainers.containers.Container

    org.testcontainers.containers.Container.ExecResult
  • Field Summary

    Fields inherited from class org.testcontainers.containers.GenericContainer

    CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategy

    Fields inherited from interface org.testcontainers.containers.ContainerState

    STATE_HEALTHY
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Constructor taking a specific webdriver container name and tag
    BrowserWebDriverContainer(org.testcontainers.utility.DockerImageName dockerImageName)
    Constructor taking a specific webdriver container name and tag
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    afterTest(org.testcontainers.lifecycle.TestDescription description, Optional<Throwable> throwable)
     
    protected void
     
    protected void
    containerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
     
    static String
    getDockerImageForCapabilities(org.openqa.selenium.Capabilities capabilities, String seleniumVersion)
    Deprecated.
    note that this method is deprecated and may be removed in the future.
    protected @NotNull Set<Integer>
     
    Deprecated.
    int
    Deprecated.
     
     
    org.openqa.selenium.remote.RemoteWebDriver
    Deprecated.
    void
     
    withCapabilities(org.openqa.selenium.Capabilities capabilities)
     
    withDesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities capabilities)
    Deprecated.
    Use withCapabilities(Capabilities capabilities) instead: withCapabilities(new FirefoxOptions())
    withLinkToContainer(org.testcontainers.containers.traits.LinkableContainer otherContainer, String alias)
    Deprecated.
    Links are deprecated (see #465).
     
    withRecordingMode(BrowserWebDriverContainer.VncRecordingMode recordingMode, File vncRecordingDirectory)
     
    withRecordingMode(BrowserWebDriverContainer.VncRecordingMode recordingMode, File vncRecordingDirectory, org.testcontainers.containers.VncRecordingContainer.VncRecordingFormat recordingFormat)
     

    Methods inherited from class org.testcontainers.containers.GenericContainer

    addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, containerIsCreated, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, failed, finished, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPortNumbers, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, hashCode, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setContainerDef, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, starting, succeeded, toString, waitingFor, waitUntilContainerStarted, withAccessToHost, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectory

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.testcontainers.containers.Container

    addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBind

    Methods inherited from interface org.testcontainers.containers.ContainerState

    copyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning

    Methods inherited from interface org.testcontainers.containers.traits.LinkableContainer

    getContainerName

    Methods inherited from interface org.testcontainers.lifecycle.Startable

    close

    Methods inherited from interface org.testcontainers.lifecycle.TestLifecycleAware

    beforeTest
  • Constructor Details

    • BrowserWebDriverContainer

      public BrowserWebDriverContainer()
    • BrowserWebDriverContainer

      public BrowserWebDriverContainer(String dockerImageName)
      Constructor taking a specific webdriver container name and tag
      Parameters:
      dockerImageName - Name of the selenium docker image
    • BrowserWebDriverContainer

      public BrowserWebDriverContainer(org.testcontainers.utility.DockerImageName dockerImageName)
      Constructor taking a specific webdriver container name and tag
      Parameters:
      dockerImageName - Name of the selenium docker image
  • Method Details

    • withCapabilities

      public SELF withCapabilities(org.openqa.selenium.Capabilities capabilities)
    • withDesiredCapabilities

      @Deprecated public SELF withDesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities capabilities)
      Deprecated.
      Use withCapabilities(Capabilities capabilities) instead: withCapabilities(new FirefoxOptions())
      Parameters:
      capabilities - DesiredCapabilities
      Returns:
      SELF
    • getLivenessCheckPorts

      @NotNull protected @NotNull Set<Integer> getLivenessCheckPorts()
      Overrides:
      getLivenessCheckPorts in class org.testcontainers.containers.GenericContainer<SELF extends BrowserWebDriverContainer<SELF>>
    • configure

      protected void configure()
      Overrides:
      configure in class org.testcontainers.containers.GenericContainer<SELF extends BrowserWebDriverContainer<SELF>>
    • getDockerImageForCapabilities

      @Deprecated public static String getDockerImageForCapabilities(org.openqa.selenium.Capabilities capabilities, String seleniumVersion)
      Deprecated.
      note that this method is deprecated and may be removed in the future. The no-args BrowserWebDriverContainer() combined with the withCapabilities(Capabilities) method should be considered. A decision on removal of this deprecated method will be taken at a future date.
      Parameters:
      capabilities - a Capabilities object for either Chrome or Firefox
      seleniumVersion - the version of selenium in use
      Returns:
      an image name for the default standalone Docker image for the appropriate browser
    • getSeleniumAddress

      public URL getSeleniumAddress()
    • getVncAddress

      public String getVncAddress()
    • getPassword

      @Deprecated public String getPassword()
      Deprecated.
    • getPort

      @Deprecated public int getPort()
      Deprecated.
    • containerIsStarted

      protected void containerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
      Overrides:
      containerIsStarted in class org.testcontainers.containers.GenericContainer<SELF extends BrowserWebDriverContainer<SELF>>
    • getWebDriver

      @Deprecated public org.openqa.selenium.remote.RemoteWebDriver getWebDriver()
      Deprecated.
      Obtain a RemoteWebDriver instance that is bound to an instance of the browser running inside a new container.

      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)

      Returns:
      a new Remote Web Driver instance
    • afterTest

      public void afterTest(org.testcontainers.lifecycle.TestDescription description, Optional<Throwable> throwable)
      Specified by:
      afterTest in interface org.testcontainers.lifecycle.TestLifecycleAware
    • stop

      public void stop()
      Specified by:
      stop in interface org.testcontainers.lifecycle.Startable
      Overrides:
      stop in class org.testcontainers.containers.GenericContainer<SELF extends BrowserWebDriverContainer<SELF>>
    • withLinkToContainer

      @Deprecated public SELF withLinkToContainer(org.testcontainers.containers.traits.LinkableContainer otherContainer, String alias)
      Deprecated.
      Links are deprecated (see #465). Please use Network features instead.
      Remember any other containers this needs to link to. We have to pass these down to the container so that the other containers will be initialized before linking occurs.
      Parameters:
      otherContainer - the container rule to link to
      alias - the alias (hostname) that this other container should be referred to by
      Returns:
      this
    • withRecordingMode

      public SELF withRecordingMode(BrowserWebDriverContainer.VncRecordingMode recordingMode, File vncRecordingDirectory)
    • withRecordingMode

      public SELF withRecordingMode(BrowserWebDriverContainer.VncRecordingMode recordingMode, File vncRecordingDirectory, org.testcontainers.containers.VncRecordingContainer.VncRecordingFormat recordingFormat)
    • withRecordingFileFactory

      public SELF withRecordingFileFactory(RecordingFileFactory recordingFileFactory)