javascript - Selenium 测试错误 Error: socket hang up
问题描述
我有一个跟随链接的脚本,登录(弹出窗口)并制作屏幕截图。在 docker 容器中组合使用(独立铬 (chromedriver+selenium) 和 nightwatch)。除一项外,所有测试都有效。
我的版本:ChromeDriver 73.0.3683.68,Selenium 服务器版本 3.141.59,nightwatch v1.0.19 我的配置 nightwatch.js:
const { Authenticator } = require('/usr/lib/node_modules/authenticator-browser-extension');
var config = {
"globals_path": "globals.js",
"output_folder": "reports",
"src_folders": ["run"],
"test_workers" : {
"enabled": true,
"workers": "auto"
},
"live_output" : true,
"test_settings": {
"default": {
"start_process" : true,
"selenium_host": "chromedriver",
"screenshots": {
"enabled": true,
"on_failure": false,
"on_error" : true,
"path": "screenshots"
},
"desiredCapabilities": {
"browserName": "chrome",
"acceptSslCerts": true,
"javascriptEnabled": true,
"acceptInsecureCerts": true,
"cssSelectorsEnabled": true,
"chromeOptions" : {
"args" : ["show-cert-link", "disable-notifications", "load-extension", "disable-popup-blocking", "no-proxy-server", "no-sandbox", "no-headless"],
"extensions": [
Authenticator.for("admin", "admin123").asBase64()
]
}
}
}
}
};
module.exports = config;
这是我在 docker-compose 中的一部分(我用 ansible 运行它):
- name: Start container with standalone-chrome
docker_container:
name: chromedriver
image: standalone-chrome:latest
recreate: yes
volumes:
- "{{playbook_dir}}/test/:/home/node/:z"
- "/etc/hosts:/etc/hosts:z"
- "/dev/shm:/dev/shm"
env:
DBUS_SESSION_BUS_ADDRESS: /dev/null
- name: Start container with nightwatch
docker_container:
name: nightwatch
image: nightwatchjs:latest
recreate: yes
links:
- "chromedriver:chromedriver"
env:
WAIT_FOR_HOSTS: chromedriver:4444
DBUS_SESSION_BUS_ADDRESS: /dev/null
volumes:
- "{{playbook_dir}}/test:/home/node"
- "/dev/shm:/dev/shm"
command: '--config nightwatch.js --test run/postdeployment.js'
cleanup: yes
detach: no
我有如下错误:
POST http://chromedriver:4444 /wd/hub/session/a4ae5b9eafe417f37d71d99e426ffbb0/url - ECONNRESET
Error: socket hang up
at createHangUpError (_http_client.js:342:15)
at Socket.socketCloseListener (_http_client.js:377:23)
Error while running .navigateTo() protocol action: An unknown error has occurred.
POST http://chromedriver:4444 /wd/hub/session/a4ae5b9eafe417f37d71d99e426ffbb0/elements - ECONNRESET
Error: socket hang up
at createHangUpError (_http_client.js:342:15)
at Socket.socketCloseListener (_http_client.js:377:23)
Error while running .locateMultipleElements() protocol action: An unknown error has occurred.
Сan你建议什么?谢谢!
解决方案
推荐阅读
- node.js - How to solve Promise Pending Error in Object.length
- python - 迭代和拆分 excel 文件名并在 Pandas 中保存为数据框
- javascript - 使用变量修改 datepicker 中的 maxDate 和 minDate
- c++ - 无法写入串行
- mariadb - MariaDB limit value of column
- docker - 如何链接在 AWS ECS 任务中运行的 2 个容器
- android - 在自定义列表视图中搜索,从工具栏 - Kotlin
- multithreading - 从 Rust 线程中的闭包内传播错误
- python - 在 Python/Pandas 中,检查逗号分隔的字符串是否包含列表中的任何值
- java - Throws clause in main method