Nightwatch.js - 无法使用反射定义类

时间:2018-05-31 23:21:32

标签: selenium-chromedriver nightwatch.js

这个错误是什么意思?我似乎无法在此处找到任何其他内容...我在根chromedriver文件夹中有selenium-server-standalonebin。提前致谢

Starting selenium server... started - PID:  33239

[Sample Tests] Test Suite
=============================

Running:  Google Header
INFO Request: POST /wd/hub/session
 - data:  {"desiredCapabilities":{"browserName":"chrome","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","chromeOptions":{"args":["start-maximized"]},"name":"Sample Tests"}}
 - headers:  {"Content-Type":"application/json; charset=utf-8","Content-Length":179}
ERROR Response 500 POST /wd/hub/session (4666ms) { value:
   { message: 'Cannot define class using reflection',
     error: 'unknown error' },
  status: 13 }

Error retrieving a new session from the selenium server

Connection refused! Is selenium server started?
{ value:
   { message: 'Cannot define class using reflection',
     error: 'unknown error' },
  status: 13 }

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" : "./bin/selenium-server-standalone-3.8.1.jar",
    "log_path" : "",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "./bin/chromedriver"
    }
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "http://localhost",
      "selenium_port"  : 4444,
      "selenium_host"  : "localhost",
      "silent": true,
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled" : true,
        "acceptSslCerts" : true,
        "chromeOptions" : {
          "args" : ["start-maximized"]
        }
      }
    }
  }

sample_tests.js (配置时占位符测试)

module.exports = {
  'Google Header'(client) {
    client
      .url('http://www.google.com')
      .waitForElementVisible('.header h1')
      .expect.element('.main').to.not.be.present;
    client.end();
  }
}

1 个答案:

答案 0 :(得分:1)

当我刷新我的机器并最终安装Java 10时,我遇到了这个问题。我们团队的其余成员仍然使用Java 9,它对他们来说很好。 我没有降级到Java 9,而是从selenium-server-standalone-3.8.1更新到selenium-server-standalone-3.12.0和chromedriver2.38 - > chromedriver2.40。

希望同样的事情对你有用。