启动Webdriver并在单个命令中运行测试用例

时间:2018-06-27 02:18:40

标签: javascript protractor cucumber

在过去的几周中,我一直在进行量角器测试。我把黄瓜和量角器结合在一起。每次我想执行一个测试用例时,我首先打开cmd提示符并执行“ webdriver-start”,然后打开一个单独的cmd提示符并运行“ protractor conf.js”以运行我的测试用例。我想知道

1)是否可以使用单个命令启动Webdriver并运行测试。我在package.json中遇到了“套件”的概念,但是找不到完整的文档。有一些简单的命令,例如“ npm test”,但现在服务器已启动,但测试未运行

2)理想情况下,我希望以环境变量作为参数运行单个命令,以便测试人员可以在其选择的环境(DIT / SIT / PROD)中运行测试。

有人可以分享一些有关如何完成此工作的见解吗?

这是我的package.json

{
  "name": "protractor-cucumber-qa-automation",
  "version": "1.0.0",
  "description": "Sample protractor-cucumber usage",
  "scripts": {

    "webdriver-start": "webdriver-manager update && webdriver-manager start",   
    "test": "npm run webdriver-start && npm run ./node_modules/protractor/bin/protractor configs/config.js"

  },
  "keywords": [],
  "author": "Tester",
  "license": "ISC",
  "dependencies": {
    "chai": "4.1.2",
    "chai-as-promised": "7.1.1",
    "chakram": "1.5.0",
    "cucumber": "^4.2.1",
    "cucumber-html-reporter": "3.0.4",
    "fs": "0.0.2",
    "oracledb": "^2.0.15",
    "path": "0.12.7",
    "protractor": "5.3.0",
    "protractor-cucumber-framework": "4.2.0",
    "request": "^2.87.0",
    "request-promise": "^4.2.2"
  }
}

1 个答案:

答案 0 :(得分:0)

您可以使用npm-run-all。它将在命令行中运行所有测试用例。