This project is no longer actively supported!
<dependency>
<groupId>com.avides.springboot.springtainer</groupId>
<artifactId>springtainer-selenium</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>
Properties consumed (in bootstrap.properties
):
embedded.container.selenium.enabled
(default istrue
)embedded.container.selenium.startup-timeout
(default is30
)embedded.container.selenium.browser-name
(default ischrome
)embedded.container.selenium.browser-docker-image-version
(default is3.141.59
)
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
import org.junit.runner.RunWith;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = RANDOM_PORT)
public class TestClass
{
@Autowired
private RemoteWebDriver embeddedSeleniumRemoteWebDriver;
@LocalServerPort
private int port;
@Test
public void testSomething()
{
String url = "http://" + ApplicationIpDetector.detect() + ":" + Integer.toString(port);
embeddedSeleniumRemoteWebDriver.get(url);
// ...
}
}
Browser Name | Docker-Image |
---|---|
Chrome | selenium/standalone-chrome-debug |
To reduce logging insert this into the logback-configuration:
<!-- Springtainer -->
<logger name="com.github.dockerjava.jaxrs" level="WARN" />
<logger name="com.github.dockerjava.core.command" level="WARN" />
<logger name="org.apache.http" level="WARN" />
<logger name="org.openqa.selenium" level="WARN" />
The container exports multiple labels to analyze running springtainers:
SPRINGTAINER_SERVICE=selenium
SPRINGTAINER_IMAGE=${embedded.container.selenium.docker-image}
SPRINGTAINER_STARTED=$currentTimestamp