此问题在此处已有答案:
Running karate tests on chrome with chromedriver inside docker(1个答案)
两年前关闭了。
我尝试使用ptrthomas/karate-chrome镜像docker。我希望在docker镜像中执行多个driver/ui空手道测试。目前使用,您的镜像docker ptrthomas/karate-chrome,但只有1个场景driver/ui成功执行。
场景是基本的:
Scenario:
Given driver 'https://github.com/login'
执行后,我有这个错误:
[ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 3][route: {}->http://localhost:9222][total available: 0; route allocated: 1 of 5; total allocated: 1 of 10]
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {}->http://localhost:9222
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to localhost/127.0.0.1:9222
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 127.0.0.1:54604<->127.0.0.1:9222
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-3: set socket timeout to 30000
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.execchain.MainClientExec - Executing request GET /json HTTP/1.1
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
karate-chrome-runner_docker | 16:07:50.206 [ForkJoinPool-2-worker-1] DEBUG org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
我尝试使用2个dockers(一个用于执行测试-maven:3.6-jdk-11,一个用于针对UI chrome -justinribeiro/chrome-headless:stable),但已经出现问题:连接失败所以,我尝试许多配置驱动程序:
karate.configure(
'driver', {
type: 'chrome',
executable: 'chrome',
// port: 9222, //default value
// host: 'localhost', //default value
showDriverLog: true,
showProcessLog: true,
start: false,
headless: true
}
)
Docker_compose:
version: '3.7'
networks:
karate: {}
services:
karate-chrome-runner:
image: ptrthomas/karate-chrome
container_name: "karate-chrome-runner_docker"
volumes:
- "~/.m2:/var/maven/.m2"
- "./:/usr/src/mymaven"
environment:
- MAVEN_CONFIG=/var/maven/.m2
working_dir: "/usr/src/mymaven"
entrypoint: "./entrypoint.sh"
networks:
- karate
请问你能帮我理解正确的操作吗?你有docker项目的例子吗?
谢谢你的帮忙
1条答案
按热度按时间jq6vz3qz1#
我不了解docker compose,但请看看Karate项目本身使用的回归测试:
karate-e2e-tests
所以docker容器是在本地构建的,测试是在其中运行的。这是批处理脚本:
build-docker.sh
这里的方法是启动名为
karate
的docker容器,并将当前文件夹中的现有测试挂载到/karate
由于上面的代码是在后台运行的,现在你可以很容易地调用命令来运行测试:
编辑:对于那些寻找如何设置跨浏览器测试,并行执行和管理大型浏览器自动化测试套件的高级指导的人,请参阅:https://stackoverflow.com/a/60387907/143475