守夜人 - 拒绝连接! Selenium Server是否已启动

时间:2017-11-02 15:50:36

标签: java selenium nightwatch.js

我试图配置Nightwatch和Selenium来尝试创建一些网络自动化。

其中有很多对我来说很新,而且该公司以前没有自动化解决方案。

我有夜视仪0.9.1.6,节点8.9.0,selenium java 3.6.0

我一直在这里关注本教程> https://www.youtube.com/watch?v=93ndNx-h1ag<这很难遵循但我相信我的步骤匹配。

当运行Nightwatch附带的google.js测试时,我会收到错误消息"连接被拒绝是Selenium Server启动了吗?"而且,确实如此。我开始了。

我的Json包含在下面,我猜测/希望这是直截了当的 - 任何帮助/指导赞赏

{
  "src_folders" : ["tests"],
  "output_folder" : "/reports",
  "custom_commands_path" : "",
  "page_objects_path" : "./examples/pages",
  "custom_assertions_path" : "",
  "globals_path" : "",
  "live_output" : false,
  "parallel_process_delay" : 10,
  "disable_colors": false,
  "test_workers" : false,

  "selenium" : {
    "start_process" : false,
    "server_path" : "./selenium",
    "log_path" : "",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "",
      "webdriver.ie.driver" : "",
      "webdriver.firefox.profile" : ""
    }
  },

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

    "saucelabs" : {
      "selenium_host" : "ondemand.saucelabs.com",
      "selenium_port" : 80,
      "username" : "${SAUCE_USERNAME}",
      "access_key" : "${SAUCE_ACCESS_KEY}",
      "use_ssl" : false,
      "silent" : true,
      "output" : true,
      "screenshots" : {
        "enabled" : false,
        "on_failure" : true,
        "path" : ""
      },
      "desiredCapabilities": {
        "name" : "test-example",
        "browserName": "firefox"
      },
      "globals" : {
        "myGlobal" : "some_sauce_global"
      },
      "selenium" : {
        "start_process" : false
      }
    },

    "phantomjs" : {
      "desiredCapabilities" : {
        "browserName" : "phantomjs",
        "javascriptEnabled" : true,
        "acceptSslCerts" : true,
        "phantomjs.binary.path" : "/path/to/phantomjs"
      }
    },

    "browserstack" : {
      "selenium" : {
        "start_process" : false
      },
      "selenium_host" : "hub.browserstack.com",
      "selenium_port" : 80,
      "silent" : true,
      "desiredCapabilities": {
        "name" : "test-example",
        "browserName": "firefox",
        "browserstack.user" : "...",
        "browserstack.key" : "..."
      }
    },

    "testingbot" : {
      "selenium_host" : "hub.testingbot.com",
      "selenium_port" : 80,
      "apiKey" : "${TB_KEY}",
      "apiSecret" : "${TB_SECRET}",
      "silent" : true,
      "output" : true,
      "screenshots" : {
        "enabled" : false,
        "on_failure" : true,
        "path" : ""
      },
      "desiredCapabilities": {
        "name" : "test-example",
        "browserName": "firefox"
      },
      "selenium" : {
        "start_process" : false
      }
    }
  }
}

1 个答案:

答案 0 :(得分:0)

我认为你被误导了。只需按照nightwatchjs.org

中的原始文档进行操作即可
     {
      "src_folders" : ["tests"],
      "output_folder" : "reports",
      "custom_commands_path" : "",
      "custom_assertions_path" : "",
      "page_objects_path" : "",
      "globals_path" : "",

      "selenium" : {
      "start_process" : true,
      "server_path" : selenium-server.jar file path,
      "log_path" : "",
      "port" : 4444,
      "cli_args" : {
      "webdriver.chrome.driver" : chromedriver path,
      "webdriver.gecko.driver" : geckodriver path,
      "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"
  }
}
}
 }

在此处查看文档http://nightwatchjs.org/gettingstarted