-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow docker image used for selenium to be specified #249
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"); | ||
|
||
/** | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. formatting issue? |
||
super.setDockerImageName(getImageForCapabilities(desiredCapabilities)); | ||
} | ||
|
||
this.desiredCapabilities = desiredCapabilities; | ||
return self(); | ||
} | ||
|
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. сan't we just inherit this tests from BaseWebDriverContainerTest? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can make the parent class abstract with |
||
public void simpleTest() throws IOException { | ||
doSimpleWebdriverTest(firefox); | ||
} | ||
|
||
@Test | ||
public void simpleExploreTest() throws IOException { | ||
doSimpleExplore(firefox); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we just check that
getDockerImageName()
is not null?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, no;
GenericContainer
sets a default image name (alpine:3.2
) on the no-args constructor. I agree with the principle, though...