Skip to content

Commit

Permalink
Allow docker image used for selenium to be specified, instead of alwa…
Browse files Browse the repository at this point in the history
…ys trying to figure out from classpath dependencies. Refs #171
  • Loading branch information
rnorth committed Dec 4, 2016
1 parent a77f068 commit 16fb9ad
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ public class BrowserWebDriverContainer<SELF extends BrowserWebDriverContainer<SE

@Nullable
private DesiredCapabilities desiredCapabilities;
private boolean imageNameIsSet = false;

@Nullable
private RemoteWebDriver driver;

private VncRecordingMode recordingMode = VncRecordingMode.RECORD_FAILING;
private File vncRecordingDirectory = new File("/tmp");

private final Collection<VncRecordingSidekickContainer> currentVncRecordings = new ArrayList<>();

private static final Logger LOGGER = LoggerFactory.getLogger(BrowserWebDriverContainer.class);

private static final SimpleDateFormat filenameDateFormat = new SimpleDateFormat("YYYYMMdd-HHmmss");

/**
Expand All @@ -53,9 +54,22 @@ public BrowserWebDriverContainer() {

}

/**
* Constructor taking a specific webdriver container name and tag
* @param dockerImageName
*/
public BrowserWebDriverContainer(String dockerImageName) {
super.setDockerImageName(dockerImageName);
this.imageNameIsSet = true;
}


public SELF withDesiredCapabilities(DesiredCapabilities desiredCapabilities) {
super.setDockerImageName(getImageForCapabilities(desiredCapabilities));

if (! imageNameIsSet) {
super.setDockerImageName(getImageForCapabilities(desiredCapabilities));
}

this.desiredCapabilities = desiredCapabilities;
return self();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.testcontainers.junit;

import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testcontainers.containers.BrowserWebDriverContainer;

import java.io.IOException;

/**
*
*/
public class SpecificImageNameWebDriverContainerTest extends BaseWebDriverContainerTest {

@Rule
public BrowserWebDriverContainer firefox = new BrowserWebDriverContainer("selenium/standalone-firefox-debug:2.53.1-beryllium")
.withDesiredCapabilities(DesiredCapabilities.firefox());

@Test
public void simpleTest() throws IOException {
doSimpleWebdriverTest(firefox);
}

@Test
public void simpleExploreTest() throws IOException {
doSimpleExplore(firefox);
}
}

0 comments on commit 16fb9ad

Please sign in to comment.