我试图评估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测试确实可以从这样的解决方案中受益。
答案 0 :(得分:0)
您可以如下更改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。