【问题标题】:Not able to run selenium grid and nightwatch无法运行 selenium grid 和 nightwatch
【发布时间】:2017-04-18 13:58:13
【问题描述】:

我正在尝试运行每个组件都位于 docker 中的测试环境(nightwatchjs、浏览器、selenium 服务器)。 但现在我一直在寻找正确的“设置”。我一直得到“连接被拒绝是 Selenium 启动”。 这很奇怪,因为我以类似的方式设置了 webdriverio 并且它可以工作(从 hulilabs repo 分叉的 repo)。 https://github.com/MichalDulemba/webdriverio

有人可以帮忙吗?

如果可行,我将为其他人创建一个 gihub/docker hub repo :)

码头工人组成:

version: '2'
services:
    nightwatch:
        image: dulemba/nightwatch
        depends_on:
            - chrome
            - firefox
            - hub
        environment:
            - HUB_PORT_4444_TCP_ADDR=hub
            - HUB_PORT_4444_TCP_PORT=4444
        volumes:
            - /home/michal/Dokumenty/nw/nightwatch/app:/app

    hub:
        image: selenium/hub
        ports:
            - 4444:4444

    firefox:
        image: selenium/node-firefox-debug
        ports:
            - 5900
        environment:
            - HUB_PORT_4444_TCP_ADDR=hub
            - HUB_PORT_4444_TCP_PORT=4444
        depends_on:
            - hub

    chrome:
        image: selenium/node-chrome-debug
        ports:
            - 5900
        environment:
            - HUB_PORT_4444_TCP_ADDR=hub
            - HUB_PORT_4444_TCP_PORT=4444
        depends_on:
            - hub

NIGHTWATCH.JSON

{
  "src_folders" : ["tests"],
  "output_folder" : "reports",
  "custom_commands_path" : "",
  "custom_assertions_path" : "",
  "page_objects_path" : "",
  "globals_path" : "",

  "selenium" : {
    "start_process" : false,
    "server_path" : "/opt/selenium/selenium-server-standalone.jar",
    "log_path" : "",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "",
      "webdriver.gecko.driver" : "",
      "webdriver.edge.driver" : ""
    }
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "http://localhost",
      "selenium_port"  : 4444,
      "selenium_host"  : "localhost",
      "silent": true,
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities": {
        "browserName": "firefox",
        "marionette": true
      }
    },

    "chrome" : {
      "desiredCapabilities": {
        "browserName": "chrome"
      }
    },

    "edge" : {
      "desiredCapabilities": {
        "browserName": "MicrosoftEdge"
      }
    }
  }
}

【问题讨论】:

    标签: selenium selenium-grid nightwatch.js


    【解决方案1】:

    我不知道这对你来说是否仍然是个问题,但这对我有用:

    docker-compose.yml

    hub:
      image: selenium/hub
      ports:
        - 4446:4444
    firefox:
      image: selenium/node-firefox-debug
      ports:
        - 4577
      links:
        - hub:hub    
    chrome:
      image: selenium/node-chrome-debug
      ports:
        - 4577
      links:
        - hub:hub
    

    ==================

    nightwatch.conf.js

    const seleniumServer = require('selenium-server');
    const chromedriver = require('chromedriver');
    const geckodriver = require('geckodriver');
    
    module.exports = {
      src_folders: ['tests'],
      output_folder: 'reports',
      custom_assertions_path: '',
      live_output: false,
      disable_colors: false,
      selenium: {
        start_process: true,
        server_path: seleniumServer.path,
        log_path: '',
        host: '127.0.0.1',
        port: 4444
      },
    
      test_settings: {
        default: {
          screenshots: {
            enabled: false,
            path: '',
            on_failure: true,
            on_error: true
          },
          launch_url: 'http://localhost',
          selenium_port: 4446,
          selenium_host: '127.0.0.1',
          desiredCapabilities: {
            browserName: 'chrome',
            javascriptEnabled: true,
            acceptSslCerts: true
          }
        },
        chrome: {
          desiredCapabilities: {
            browserName: 'chrome',
            javascriptEnabled: true,
            acceptSslCerts: true
          },
          selenium: {
            cli_args: {
              'webdriver.chrome.driver': chromedriver.path
            }
          }
        },
        firefox: {
          desiredCapabilities: {
            browserName: 'firefox',
            javascriptEnabled: true,
            marionette: true
          },
          selenium: {
            cli_args: {
              'webdriver.gecko.driver': geckodriver.path
            }
          }
        }
      }
    };
    

    干杯!

    【讨论】:

      猜你喜欢
      • 2018-04-09
      • 1970-01-01
      • 2019-12-19
      • 1970-01-01
      • 1970-01-01
      • 2016-04-25
      • 2016-12-09
      • 2017-05-23
      • 1970-01-01
      相关资源
      最近更新 更多