无法运行硒网格和夜视仪

时间:2017-04-18 13:58:13

标签: selenium selenium-grid nightwatch.js

我正在尝试运行测试环境,其中每个组件都在docker(nightwatchjs,browser,selenium server)中。 但现在我陷入了寻找正确“设置”的困境。我一直得到“连接被拒绝是Selenium开始”。 这很奇怪,因为我以类似的方式设置webdriverio并且它可以工作(来自hulilabs repo的repo)。 https://github.com/MichalDulemba/webdriverio

有人可以帮忙吗?

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

DOCKER COMPOSE:

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"
      }
    }
  }
}

1 个答案:

答案 0 :(得分:0)

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

搬运工-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
        }
      }
    }
  }
};

干杯!