NightwatchJS-手动运行Selenium Server时无法创建会话

时间:2018-09-12 18:54:27

标签: selenium nightwatch.js

我遇到了这个奇怪的问题,我可以在3台机器中的2台上重现...如果手动运行Nightwatch,则无法连接到Selenium Server。如果我让Nightwatch处理Selenium Server,那就没有问题。

我尝试了多个Selenium和Chromedriver(必需的浏览器,但所有其他浏览器均出现此问题)版本。在一台机器上工作,在另外两台机器上失败。

这是我的Nightwatch.json文件:

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

  "selenium" : {
    "start_process" : false,
    "start_session" : true,
    "server_path" : "./selenium-server-standalone-3.14.0.jar",
    "log_path" : "",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "./chromedriver_2.41.exe"
    }
  },

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

我正在使用以下命令运行Selenium服务器:

java -jar selenium-server-standalone-3.14.0.jar -debug

我通过以下方式运行测试

nightwatch -t demo_test_google.js

运行测试后得到的结果: 硒服务器:

21:48:15.693 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.14.0', revision: 'aacccce0'
21:48:15.694 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444
2018-09-12 21:48:15.792:INFO::main: Logging initialized @371ms to org.seleniumhq.jetty9.util.log.StdErrLog
21:48:16.145 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
21:48:21.340 DEBUG [WebDriverServlet.handle] - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@774638b9
21:48:21.345 DEBUG [WebDriverServlet.lambda$handle$3] - /session: Executing POST on /session (handler: BeginSession)
21:48:21.469 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "acceptSslCerts": true,
  "browserName": "chrome",
  "javascriptEnabled": true,
  "name": "Demo Test Google"
}
21:48:21.471 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)

NightwatchJS测试:

Running:  Demo test Google

Error retrieving a new session from the selenium server

Connection refused! Is selenium server started?
{ value:
   { message: 'Unable to create new service: ChromeDriverService\nBuild info: version: \'3.14.0\', revision: \'aacccce0\', time: \'2018-08-02T20:13:22.693Z\'\nSystem info: host: \'xxxxxxxxxxxx\', ip: \'xxx.xxx.xxx.xxx\', os.name: \'Windows 10\', os.arch: \'amd64\', os.version: \'10.0\', java.version: \'1.8.0_181\'\nDriver info: driver.version: unknown',
     error: 'session not created' },
  status: 33 }

任何帮助将不胜感激! 预先感谢!

0 个答案:

没有答案
相关问题