![](/img/trans.png)
[英]How can I get container ID in order to execute command in docker container?
[英]2.1.0 requires minimum docker version?
我正在嘗試評估Selenium-Jupiter,但是會遇到不同的問題,其行為取決於我使用的版本。
我正在使用gradle 4.6和
> docker version | grep API
API version: 1.24
API version: 1.24
使用io.github.bonigarcia:selenium-jupiter:2.1.0
gradle clean test --info
...
Caused by:
io.github.bonigarcia.SeleniumJupiterException: io.github.bonigarcia.SeleniumJupiterException: com.spotify.docker.client.exceptions.ContainerNotFoundException: Container not found: c222d04fa9726606939b34d27565345d5462dbc9e6744e438a662099325c573a
Caused by:
io.github.bonigarcia.SeleniumJupiterException: com.spotify.docker.client.exceptions.ContainerNotFoundException: Container not found: c222d04fa9726606939b34d27565345d5462dbc9e6744e438a662099325c573a
Caused by:
com.spotify.docker.client.exceptions.ContainerNotFoundException: Container not found: c222d04fa9726606939b34d27565345d5462dbc9e6744e438a662099325c573a
Caused by:
com.spotify.docker.client.exceptions.DockerRequestException: Request error: POST unix://localhost:80/containers/c222d04fa9726606939b34d27565345d5462dbc9e6744e438a662099325c573a/start: 404, body: {"message":"invalid header field value \"oci runtime error: container_linux.go:247: starting container process caused \\\"exec: \\\\\\\"\\\\\\\": executable file not found in $PATH\\\"\\n\""}
Caused by:
javax.ws.rs.NotFoundException: HTTP 404 Not Found
使用io.github.bonigarcia:selenium-jupiter:2.0.0
gradle clean test --info
...
Caused by:
io.github.bonigarcia.SeleniumJupiterException: io.github.bonigarcia.SeleniumJupiterException: org.openqa.selenium.WebDriverException: create container: Error response from daemon: client is newer than server (client API version: 1.30, server API version: 1.24) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 31 milliseconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'xxxx', ip: '10.167.6.18', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-514.21.1.el7.x86_64', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
Caused by:
io.github.bonigarcia.SeleniumJupiterException: org.openqa.selenium.WebDriverException: create container: Error response from daemon: client is newer than server (client API version: 1.30, server API version: 1.24) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 31 milliseconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'xxxx', ip: '10.167.6.18', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-514.21.1.el7.x86_64', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
Caused by:
org.openqa.selenium.WebDriverException: create container: Error response from daemon: client is newer than server (**client API version: 1.30, server API version: 1.24**) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 31 milliseconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'xxxx', ip: '10.167.6.18', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-514.21.1.el7.x86_64', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
我假設Selenium-Jupiter和Selenoid之間的交互需要一些配置,例如DOCKER_API_VERSION
,如此處http://aerokube.com/selenoid/latest/#_recommended_docker_settings所述,但我不知道從Selenium-木星這邊的東西。
我意識到這是一個相當大的求助者,但希望至少有人能給我一些有關如何解決此問題的提示。 我真的很喜歡使用Docker進行這種虛擬化的想法,我認為我們的GUI測試確實可以從這樣的解決方案中受益。
您可以按以下方式更改Selenium-Jupiter使用的Docker API的版本:
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openqa.selenium.WebDriver;
import io.github.bonigarcia.seljup.SeleniumExtension;
public class MyTest {
@RegisterExtension
static SeleniumExtension seleniumExtension = new SeleniumExtension();
@BeforeAll
static void setup() {
seleniumExtension.getConfig().setDockerApiVersion("API-version"); // 1.35 by default
}
@Test
void test(WebDriver driver) {
// your test
}
}
在撰寫本文時,我將使用最新版本的Selenium-Jupiter 3.1.0。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.