首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nightwatch chromedriver

Nightwatch chromedriver
EN

Stack Overflow用户
提问于 2016-04-27 15:22:04
回答 6查看 2.8K关注 0票数 1

我不能运行nightwatch来运行chrome上的测试。

这是我从nightwatch示例下载的修改后的nightwatch.json:

代码语言:javascript
复制
{
  "src_folders" : ["./examples/tests"],
  "output_folder" : "./examples/reports",
  "custom_commands_path" : "./examples/custom-commands",
  "custom_assertions_path" : "",
  "globals_path" : "./examples/globals.json",
  "live_output" : false,

  "selenium" : {
    "start_process" : false,
    "server_path" : "/lib/sel-serv.jar",
    "log_path" : "",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "/lib/chromedriver/chromedriver.exe",
      "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" : ""
      },
      "chrome":{
      "desiredCapabilities" : {
        "browserName" : "chrome",
        "javascriptEnabled" : true,
        "acceptSslCerts" : true
      }
      }
    },


      "desiredCapabilities": {
        "name" : "test-example",
        "browserName": "chrome"
      },
      "globals" : {
        "myGlobal" : "some_sauce_global"
      },
      "selenium" : {
        "start_process" : false
      }
  }
}

我得到了这个错误信息:

代码语言:javascript
复制
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:448:15)
    at Object.CliRunner.init (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:49:8)
    at module.exports.runner.runner (/usr/local/lib/node_modules/nightwatch/lib/index.js:546:17)
    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:5)
    at Object.<anonymous> (/usr/local/lib/node_modules/nightwatch/bin/runner.js:8:14)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)

我还发现了一个旧的帖子,说你必须在根目录中创建新文件,所以试一试,什么也没有发生

EN

回答 6

Stack Overflow用户

发布于 2016-04-28 19:37:57

我认为你需要在lib前加一个点:

代码语言:javascript
复制
"webdriver.chrome.driver" : "./lib/chromedriver/chromedriver.exe",

还有selenium.jar:

代码语言:javascript
复制
"server_path" : "./lib/sel-serv.jar",
票数 3
EN

Stack Overflow用户

发布于 2017-05-16 15:17:37

Selenium服务器jar路径和chrome驱动程序(.exe)路径设置不正确。使用点(“.”)在设置路径之前表示您的工作目录。或者删除chrome驱动程序和selenium服务器jar文件路径前的正斜杠(“/”)。

您必须手动运行Selenium服务器独立jar文件,因为您没有将"start_process“设置为"true”。在此处检查Selenium配置:http://nightwatchjs.org/gettingstarted/

您已经两次将start_process属性设置为false。从json文件中删除最后一个元素。("selenium“:{ "start_process”:false })

在开始执行之前,还要检查浏览器版本和驱动程序是否兼容。(检查下载驱动程序的自述文件。在readMe文件的第一行将有浏览器兼容版本)。

票数 2
EN

Stack Overflow用户

发布于 2017-11-29 19:00:05

只需检查配置文件并将chrome对象放入默认对象之外,例如,

代码语言:javascript
复制
     "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" : ""
  }
  },
    "chrome":{
  "desiredCapabilities" : {
    "browserName" : "chrome",
    "javascriptEnabled" : true,
    "acceptSslCerts" : true
  }
},

    like this....have a blast
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36883009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档