从selenium服务器检索新会话时出错

时间:2016-11-04 22:16:22

标签: javascript selenium webdriver nightwatch.js

我第一次尝试设置Nightwatch.js。我遵循以下教程:https://github.com/dwyl/learn-nightwatch

不幸的是,我遇到了障碍,而且我需要帮助解决它。

  

从selenium服务器检索新会话时出错。    拒绝连接! selenium服务器是否已启动?

enter image description here

nightwatch.conf.js

module.exports = {
  "src_folders": [
    "test"// Where you are storing your Nightwatch e2e/UAT tests
  ],
  "output_folder": "./reports", // reports (test outcome) output by nightwatch
  "selenium": { 
    "start_process": true, // tells nightwatch to start/stop the selenium process
    "server_path": "./node_modules/nightwatch/bin/selenium.jar",
    "host": "127.0.0.1",
    "port": 4444, // standard selenium port
    "cli_args": {  
      "webdriver.chrome.driver" : "./node_modules/nightwatch/bin/chromedriver"
    }
  },
  "test_settings": {
    "default": {
      "screenshots": {
        "enabled": true, // if you want to keep screenshots
        "path": './screenshots' // save screenshots here
      },
      "globals": {
        "waitForConditionTimeout": 5000 // sometimes internet is slow so wait.
      },
      "desiredCapabilities": { // use Chrome as the default browser for tests
        "browserName": "chrome"
      }
    },
    "chrome": {
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true // set to false to test progressive enhancement
      }
    }
  }
}

豚鼠pig.js

module.exports = { // addapted from: https://git.io/vodU0
  'Guinea Pig Assert Title': function(browser) {
    browser
      .url('https://saucelabs.com/test/guinea-pig')
      .waitForElementVisible('body')
      .assert.title('I am a page title - Sauce Labs')
      .saveScreenshot('ginea-pig-test.png')
      .end();
  }
};

基于配置设置。我尽可能保持基本。我无法确定它建议另一个selenium服务器启动的来源。有什么想法吗?

编辑:超时错误

enter image description here

3 个答案:

答案 0 :(得分:1)

在你的nightwatch.json文件中," selenium"

确保您的服务器路径正确无误。 确保您的webdriver.chrome.driver路径正确无误。

这些特定于您的机器。如果那些没有在正确的位置引用正确的文件,那么启动selenium服务器时会遇到问题。

之后,您要确保您使用的版本的selenium服务器与您拥有的Chrome驱动程序版本配合使用,并且该版本适用于您拥有的Chrome浏览器版本。

但正如Krishnan Mahadevan所示,如果没有完整的错误消息,我们就无法提供更多帮助。

答案 1 :(得分:1)

该解决方案涉及删除我的Chrome实例(尽管它是最新版本),只是重新安装浏览器。

我鼓励所有人面临同样的问题,首先看看QualiT的上述回应,因为它是更常规的故障排除策略。

答案 2 :(得分:1)

我在项目中使用<add value="Negotiate:Kerberos" /> 时遇到了同样的问题。在我更新到Java 9之后,这个问题得到了解决。

相关问题