2017-04-18 63 views
0

我想运行测试环境,其中每个组件在docker(nightwatchjs,browsers,selenium server)中。 但现在我被困在找到正确的“设置”。我一直得到“连接被拒绝是Selenium开始的”。 这很奇怪,因为我以类似的方式设置了webdriverio,并且工作正常(从hulilabs回购库中分叉)。 https://github.com/MichalDulemba/webdriverio无法运行硒网格和夜间

有人可以帮忙吗?

如果一切正常,我会为其他人:)

码头工人组成一个gihub /泊坞窗枢纽回购:

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

回答

0

我不知道如果这仍然是你的问题,但这对我很有用:

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

干杯!