硒测试错误错误:套接字挂起

时间:2019-04-19 11:30:37

标签: javascript selenium selenium-webdriver selenium-chromedriver nightwatch.js

我有一个跟随链接,登录(弹出窗口)并截图的脚本。在Docker容器中组合使用(独立铬(chromedriver(铬驱动器+硒)和守夜)。除一项外,所有测试均有效。

我的版本:ChromeDriver 73.0.3683.68,Selenium服务器版本3.141.59,夜视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您有建议吗?谢谢!

0 个答案:

没有答案