【发布时间】:2021-12-23 03:44:46
【问题描述】:
我在 Gitlab CI 中运行 selenium 测试,但在使用 gitlab 运行器而不是我的计算机时正确设置远程 URL 时遇到问题。
跑步者的IP地址是192.168.xxx.xxx。当我运行管道时,我得到 selenium hub 的 IP 地址是172.19.0.2/16。我都试过了,都失败了。我也试过用selenium hub容器的名字http://selenium__hub,但是也失败了。
docker-compose.yml 是:
version: "3"
services:
chrome:
image: selenium/node-chrome:4.0.0-20211013
container_name: chrome
shm_size: 2gb
depends_on:
- selenium-hub
volumes:
- ./target:/home/seluser/Downloads
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_GRID_URL=http://localhost:4444
ports:
- "6900:5900"
edge:
image: selenium/node-edge:4.0.0-20211013
container_name: edge
shm_size: 2gb
depends_on:
- selenium-hub
volumes:
- ./target:/home/seluser/Downloads
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_GRID_URL=http://localhost:4444
ports:
- "6901:5900"
firefox:
image: selenium/node-firefox:4.0.0-20211013
container_name: firefox
shm_size: 2gb
depends_on:
- selenium-hub
volumes:
- ./target:/home/seluser/Downloads
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_GRID_URL=http://localhost:4444
ports:
- "6902:5900"
selenium-hub:
image: selenium/hub:4.0.0-20211013
container_name: selenium-hub
ports:
- "4444:4444"
gitlab runner 的配置文件如下所示:
[[runners]]
name = "selenium"
url = "https://gitlab.myhost.at"
token = "xxxxxxxx"
executor = "docker"
privileged = true
links = ["selenium__hub:hub"]
[runners.docker]
image = "docker:stable"
privileged = true
我试过的远程网址是:
WebDriver driver = new RemoteWebDriver(new URL("http://192.168.xxx.xxx:4444/wd/hub"), cap);
WebDriver driver = new RemoteWebDriver(new URL("http://172.19.0.2:4444/wd/hub"), cap);
WebDriver driver = new RemoteWebDriver(new URL("http://selenium__hub:4444/wd/hub"), cap);
我怎样才能让它与 GitLab 跑步者一起工作?
【问题讨论】:
-
可以编辑您的问题以包含您使用的 GitLab 作业配置和作业脚本吗?这样我们就可以知道你的工作是如何连接到 docker daemon/containers 的。还请准确描述“失败”的含义,您所看到的错误到底是什么。 -- 作为一个可能的注释,underscores are not RFC compliant in hostnames。这不应该是浏览器的问题,但以防万一,也许可以尝试为您的集线器服务使用不同的名称...但我怀疑问题是您的工作的网络设置。
-
我已经编辑了您的问题标题和描述,以提高所问内容的清晰度。如果您觉得我在这方面有任何错误,请随时将其改回。
-
@sytech 很抱歉打扰您。你能看看另一个与 docker 和 gitlab CI 相关的话题吗?谢谢。 stackoverflow.com/questions/69974278/…
标签: docker selenium gitlab-ci gitlab-ci-runner selenium-rc