在本地码头管道上运行nightwatch + selenium的问题

问题描述 投票:1回答:1

我在本地Docker镜像上运行简单的夜间测试文件时遇到问题。我想弄清楚为什么selenium不想运行本地测试。如果有人认为这一点,任何帮助将不胜感激。谢谢!

这是我的测试文件:

NW-example.test.js

module.exports = {
  'End-to-end all browsers' : function (browser) {
    browser
      .init('http://localhost:3000/')
      .setValue('#loginForm-username', '')
      .setValue('#loginForm-password', '')
      .pause(2000)
      .click('#loginForm-submit')
      .perform(function(done){
        console.log('Done testing')
        done()
      })
      .pause(3000)
      .assert.containsText('#app','Welcome,');
  }
};

这是我的nightwatch.json文件:

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

  "selenium" : {
    "start_process" : true,
    "server_path" : "",
    "log_path" : "",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "./usr/local/bin/chromedriver",
      "webdriver.gecko.driver" : "./usr/local/bin/geckodriver",
      "webdriver.edge.driver" : "",
      "webdriver.safari.driver" : ""
    }
  },

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

    "chrome" : {
      "desiredCapabilities": {
        "browserName": "chrome",
        "chromeOptions" : {
          "args" : ["headless", "--no-sandbox"]
        }
      }
    },

    "firefox" : {
      "desiredCapabilities": {
        "browserName": "firefox"
      }
    },

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

    "safari" : {
      "desiredCapabilities": {
        "browserName": "safari",
        "javascriptEnabled": true
      }
    }
  }
}

我得到的错误:

root@2b755e5a6174:/vital-webapp/src/__tests__# nightwatch nw-example.test.js 

[Nw Example Test] Test Suite
================================

Running:  End-to-end all browsers
20:13:49.642 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@2465e6e1
20:13:49.643 INFO - /session: Executing POST on /session (handler: BeginSession)
20:13:49.646 INFO - Capabilities are: Capabilities {acceptSslCerts: true, browserName: chrome, javascriptEnabled: true, marionette: true, name: Nw Example Test}
20:13:49.646 INFO - Capabilities {acceptSslCerts: true, browserName: chrome, javascriptEnabled: true, marionette: true, name: Nw Example Test} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881) on port 4516
Only local connections are allowed.
20:13:59.737 WARN - timeout
java.net.SocketTimeoutException: timeout
selenium docker nightwatch.js bitbucket-pipelines
1个回答
1
投票

错误说明了一切:

20:13:49.646 INFO - Capabilities are: Capabilities {acceptSslCerts: true, browserName: chrome, javascriptEnabled: true, marionette: true, name: Nw Example Test}
20:13:49.646 INFO - Capabilities {acceptSslCerts: true, browserName: chrome, javascriptEnabled: true, marionette: true, name: Nw Example Test} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881) on port 4516
Only local connections are allowed.
20:13:59.737 WARN - timeout
java.net.SocketTimeoutException: timeout

在配置ChromeDriver时,您已经提供了以下所需的功能:

  "desiredCapabilities": {
    "browserName" : "chrome",
    "javascriptEnabled" : true,
    "marionette" : true,
    "acceptSslCerts" : true
  }

ChromeDriver没有“marionette”这样设置为true的功能。

删除“marionette”功能:true并执行你的@Test

© www.soinside.com 2019 - 2024. All rights reserved.