Skip to content
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

Add convenience methods to interact with container #69

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ class ContainerGebSpec extends GebSpec {
throw new IllegalStateException('Test class must be annotated with @Integration for serverPort to be injected')
}
webDriverContainer = new BrowserWebDriverContainer()
Testcontainers.exposeHostPorts(serverPort)
webDriverContainer.tap {
addExposedPort(serverPort)
withAccessToHost(true)
start()
}
Testcontainers.exposeHostPorts(serverPort)
if (hostName != DEFAULT_HOSTNAME) {
webDriverContainer.execInContainer('/bin/sh', '-c', "echo '$hostIp\t$hostName' | sudo tee -a /etc/hosts")
}
Expand All @@ -82,6 +82,18 @@ class ContainerGebSpec extends GebSpec {
webDriverContainer?.stop()
}

/**
* Get access to container running the web-driver, for convenience to execInContainer, copyFileToContainer etc.
*
* @see org.testcontainers.containers.ContainerState#execInContainer(java.lang.String ...)
* @see org.testcontainers.containers.ContainerState#copyFileToContainer(org.testcontainers.utility.MountableFile, java.lang.String)
* @see org.testcontainers.containers.ContainerState#copyFileFromContainer(java.lang.String, java.lang.String)
* @see org.testcontainers.containers.ContainerState
*/
BrowserWebDriverContainer getContainer() {
return webDriverContainer
}

/**
* Returns the protocol that the browser will use to access the server under test.
* <p>Defaults to {@code http}.
Expand Down
Loading