Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

springtainer/springtainer-selenium

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

springtainer-selenium

Maven Central Build Nightly build Coverage report Quality Gate Technical dept

Attention

This project is no longer actively supported!

Dependency

<dependency>
  <groupId>com.avides.springboot.springtainer</groupId>
  <artifactId>springtainer-selenium</artifactId>
  <version>2.0.0</version>
  <scope>test</scope>
</dependency>

Configuration

Properties consumed (in bootstrap.properties):

  • embedded.container.selenium.enabled (default is true)
  • embedded.container.selenium.startup-timeout (default is 30)
  • embedded.container.selenium.browser-name (default is chrome)
  • embedded.container.selenium.browser-docker-image-version (default is 3.141.59)

Example

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);

        // ...
    }
}

Supported Browsers

Browser Name Docker-Image
Chrome selenium/standalone-chrome-debug

Logging

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" />

Labels

The container exports multiple labels to analyze running springtainers:

  • SPRINGTAINER_SERVICE=selenium
  • SPRINGTAINER_IMAGE=${embedded.container.selenium.docker-image}
  • SPRINGTAINER_STARTED=$currentTimestamp