首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >设置Nightwatch.js Conf文件

设置Nightwatch.js Conf文件
EN

Stack Overflow用户
提问于 2017-04-28 15:46:32
回答 2查看 993关注 0票数 0

我是夜莺的新手,我正试着运行这个命令

$ nightwatch --env gecko /test1/test1 1/sample1.js

我试图弄清楚如何通过命令行从nightwatch.json文件中选择浏览器。

这是我的文件。我正在阅读关于Nightwatch.js的教程,似乎找不到这个设置。

代码语言:javascript
复制
{
"src_folders": [
    "tests"
],
"selenium": {
    "start_process": false,
    "server_path": "bin/selenium-server-standalone-2.53.1.jar",
    "log_path": "",
    "host": "127.0.0.1",
    "port": 4444,
    "cli_args": {
        "webdriver.chrome.driver": "bin/chromedriver",
        "webdriver.gecko.driver" : "bin/geckodriver"
    }
},
"test_settings": {
    "default": {
        "launch_url": "http://127.0.0.1/",
        "selenium_port": 4444,
        "selenium_host": "localhost",
        "silent": true,
        "screenshots": {
            "enabled": false,
            "path": ""
        },
        "desiredCapabilities": {
            "browserName": "chrome",
            "javascriptEnabled": true,
            "acceptSslCerts": true
        }
    }
    "gecko": {
    "launch_url": "http://127.0.0.1/",
    "selenium_port": 4444,
    "selenium_host": "localhost",
    "silent": true,
    "screenshots": {
        "enabled": false,
        "path": ""
    },
    "desiredCapabilities": {
        "browserName": "gecko",
        "javascriptEnabled": true,
        "acceptSslCerts": true
        }
    }
}
}

我得到的错误信息是

代码语言:javascript
复制
Error: No testing environment specified.
    at CliRunner.parseTestSettings (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:515:13)
    at CliRunner.setup (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:49:8)
    at Object.exports.runner (/usr/local/lib/node_modules/nightwatch/lib/index.js:551:17)
    at /usr/local/lib/node_modules/nightwatch/bin/runner.js:10:16
    at Object.exports.cli (/usr/local/lib/node_modules/nightwatch/lib/index.js:545:5)
    at Object.<anonymous> (/usr/local/lib/node_modules/nightwatch/bin/runner.js:8:14)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
EN

回答 2

Stack Overflow用户

发布于 2017-04-28 22:12:18

不确定是不是这样,但您至少在这里需要一个逗号:

代码语言:javascript
复制
},
    "gecko"
票数 0
EN

Stack Overflow用户

发布于 2017-05-04 08:38:08

可以尝试使用以下代码:

代码语言:javascript
复制
  {
  "src_folders": [
    "tests"
  ],
  "output_folder": "reports",
  "custom_commands_path": "",
  "custom_assertions_path": "",
  "page_objects_path": "pages",
  "globals_path": "",
  "selenium": {
    "start_process": false,
    "server_path": "bin/selenium-server-standalone-2.53.1.jar",
    "start_session": true,
    "log_path": "",
    "host": "127.0.0.1",
    "port": 4444,
    "cli_args": {
      "webdriver.chrome.driver": "bin/chromedriver",
      "webdriver.gecko.driver" : "bin/geckodriver"
    }
  },
  "test_settings": {
    "default": {
      "launch_url" : "http://localhost",
      "selenium_port": 4444,
      "selenium_host": "localhost",
      "silent": true,
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    },
    "gecko": {
      "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    }
  }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43684160

复制
相关文章

相似问题

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