本文介绍了守夜人-使用chromedriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在堆栈上看到了类似的问题,但是它没有得到接受的答案,也没有为我提供所需的信息.

So i saw a similar question on stack here but it did not have an accepted answer nor did it provide me with the information i needed..

我正在尝试使用"chromedriver",因为"selenium-webdriver"需要FF版本< = 28.

I am trying to use 'chromedriver' because 'selenium-webdriver' requires a FF version <= 28.

到目前为止我所做的.

  • nightwatch.js测试可以在FF中正常运行
  • 将chromedriver(npm install chromedriver -g)和npm install chromedriver下载到了我的守夜项目目录中
  • 转到nightwatch/bin/nightwatch.json并编辑以下代码

  • nightwatch.js tests running fine in FF
  • downloaded chromedriver (npm install chromedriver -g) and also npm install chromedriver into my nightwatch project directory
  • went to nightwatch/bin/nightwatch.json and edited the following code

 "selenium" : {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
  "webdriver.chrome.driver" : "/usr/local/bin/chromedriver", <= added this - is this the binary?
  "webdriver.ie.driver" : "",
  "webdriver.firefox.profile" : ""
}},

还尝试将硒的设置更新为具有start_process = true和server_path

also tried to update the settings for selenium to have a start_process=true and server_path

 "selenium" : {
    "start_process" : true,
    "server_path" : "../selenium-server-standalone-2.39.0.jar",
    "log_path" : "",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "/usr/local/bin/chromedriver",
      "webdriver.ie.driver" : "",
      "webdriver.firefox.profile" : ""
    }
  },

不确定我是否指向正确的chromedriver文件/文件夹

Not sure if im pointing to the proper chromedriver file/folder

还编辑了测试设置

  "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" : "chrome",   <= changed this from ff to chrome
        "javascriptEnabled" : true,
        "acceptSslCerts" : true
      }
    },

如果我去运行测试(没有-e <browser>),例如nightwatch -g <group>,它可以在FF中正常启动并运行..

If i go to run the test (without a -e <browser>) e.g. nightwatch -g <group>, it launches fine in FF and runs..

如果我尝试指定Chrome浏览器(-e chrome)nightwatch -g <group> -e chrome,则会出现以下错误

If i try to specify the chrome browser (-e chrome) nightwatch -g <group> -e chrome i get the following error

ERROR There was an error while starting the test runner:


Error: Invalid testing environment specified: chrome
    at Object.CliRunner.parseTestSettings (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:354:15)
    at Object.CliRunner.init (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:31:8)
    at module.exports.runner.runner (/usr/local/lib/node_modules/nightwatch/lib/index.js:512:19)
    at /usr/local/lib/node_modules/nightwatch/bin/runner.js:9:16
    at module.exports.cli.cli (/usr/local/lib/node_modules/nightwatch/lib/index.js:504:7)
    at Object.<anonymous> (/usr/local/lib/node_modules/nightwatch/bin/runner.js:8:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

我的问题是:

  1. 我如何指向二进制文件(不确定是哪个文件)

  1. How do i point to the binary file (not sure which it is)

nightwatch.js中的设置是否正确?如果我更改了test_settings'browserName = Chrome,它如何在FF中运行?

Are my settings in nightwatch.js correct? How is it running in FF if i changed the test_settings 'browserName = Chrome"?

我在这里想念什么吗?

预先感谢

推荐答案

请确保在项目的根目录中创建一个新的nightwatch.json文件.

Make sure to create a new nightwatch.json file in the root of your project.

我犯的错误是试图使用软件包附带的nightwatch.json文件,该文件来自 http://nightwatchjs.org /驻留在nightwatch-0.6.11/bin/nightwatch.json

The mistake i made was trying to use the nightwatch.json file that came with the package downlaoded from http://nightwatchjs.org/ that resided in nightwatch-0.6.11/bin/nightwatch.json

这篇关于守夜人-使用chromedriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 20:06