docker - selenium docker image selenium/node-chrome:3.11.0-dysprosium 适用于 Chrome 66,但使用 chrome 81 派生的自定义映像无法开始测试
问题描述
我正在我的项目中实现 selenium docker 网格。在使用更新的浏览器版本连接自定义的 node-chrome docker 节点容器时,我遇到了问题。以下是详细信息。
环境:Windows 10 基础机 Ubuntu 18.04/16.04 虚拟机。
项目:Python Pytest Selenium
使用 selenium/hub:3.11.0-dysprosium 和 selenium/node-chrome:3.11.0-dysprosium 运行测试用例运行良好。该图像是使用 selenium-server-standalone-3.11.0.jar 和 chrome 版本 66 创建的,这些图像是从https://hub.docker.com/下载的
然后,基于 selenium-server-standalone-3.11.0.jar 并使用最新的 chrome/chormedriver 版本(即 81)创建自定义 docker 映像。
创建 docker 镜像的步骤:
请参考 https://github.com/SeleniumHQ/docker-selenium/wiki/Building-your-own-images
• git clone https://github.com/SeleniumHQ/docker-selenium.git
• cd docker-selenium
• git checkout tags/3.11.0-dysprosium
• make generate_all
• sudo docker build -t selenium/node-chrome:1.2 --build-arg CHROME_DRIVER_VERSION=81.0.4044.69 --build-arg CHROME_VERSION=google-chrome-stable=81.0.4044.92-1 NodeChrome
构建映像后,我将在 docker-compose 文件中使用此本地映像。
hub和node启动成功,chrome会话也创建了,但是python+pytest测试挂了。
[1586871890.350][SEVERE]: bind() failed: Cannot assign requested address (99) [Based on the googling, actually this error should not be a stopper to test run, but mentioning it here]
“13:44:50.256 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776}) on port 17653
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1586871890.350][SEVERE]: bind() failed: Cannot assign requested address (99)
13:44:50.850 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
13:44:50.927 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 98b823ca35a6d3cc17e666b7911551c4 (org.openqa.selenium.chrome.ChromeDriverService)”
通过独立服务器节点和集线器(不带 docker)运行相同的测试通过,并且测试在 chrome 浏览器版本 80+ 上运行。请注意,项目代码尚未更新以适用于 selenium-server-standalone 上的更高版本。
Docker-compose.yml
services:
selenium-hub:
image: selenium/hub:3.11.0-dysprosium
container_name: selenium-hub
ports:
- "4444:4444"
environment:
- GRID_DEBUG=true
chrome:
image: selenium/node-chrome:1.2
depends_on:
- selenium-hub
ports:
- 9901:9500
- 5555:5555
expose:
- "9515"
- "5555"
environment:
- GRID_DEBUG=true
- HUB_HOST=selenium-hub
- HUB_PORT=4444
- NODE_BROWSER_NAME=chrome
- NODE_SELENIUM_PROTOCOL=WebDriver
- DBUS_SESSION_BUS_ADDRESS=/dev/null
- NODE_MAX_INSTANCES=2
- NODE_MAX_SESSION=2
- VNC_NO_PASSWORD=1
volumes:
- /dev/shm:/dev/shm
links:
- selenium-hub
privileged: true
解决方案
推荐阅读
- visual-studio-code - 如何防止 vscode 在文件末尾修改换行符?
- javascript - 在每个 html 元素中使用动态 id 的原因或好处是什么
- vue.js - 如何一次同时转换两个元素?
- apache-kafka - Nest.JS 上的卡夫卡
- jquery - 迭代 JSON 并分别取出每个值
- php - 使用标准键重建数组
- json - Angular 6 动态复选框表单“错误:找不到名称为‘P1’的控件”
- java - 无法运行弹簧应用程序...错误:org.springframework.boot:spring-boot-maven-plugin:1.5.6.RELEASE:run
- java - 自定义请求生成器 Apache
- jquery - 将模型的属性作为参数传递给视图控制器