首页 > 解决方案 > 错误:运行 Protractor 端到端测试时找不到 update-config.json

问题描述

我有一个 Angular 6 项目并尝试运行端到端量角器测试。我在这一步中不断收到此错误:

webdriver-manager update --standalone false --gecko false

所以我全局安装了webdriver-manager,webdriver-manager文件夹在文件夹中:C:\Users...\Roaming\npm\node_modules

然后,我使用文件夹 C:/User/ 中的此命令更新 webdriver-manager:

webdriver-manager update

这成功地添加了 selenium jar、chromedriver 和 geckodriver。

我尝试使用纱线运行端到端测试。当脚本到达此命令时:

webdriver-manager update --standalone false --gecko false

我收到此错误: 在此处输入图像描述

update-config.json 位于文件夹中: 在此处输入图像描述

这个 json 文件应该在哪里,我如何得到它?

更新 这些是当前脚本:

"scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config local.proxy.config.json",
    "build": "ng build --output-path ../resources/static",
    "test": "ng test",
    "test-local": "ng test --karmaConfig=karma-local.conf.js",
    "lint": "ng lint",
    "wd:update": "npm run e2e-update && protractor ./e2e/protractor-local.conf.js",
    "wd:start": "webdriver-manager start && protractor ./e2e/protractor-local.conf.js",
    "e2e-local": "npm run e2e-update && protractor ./e2e/protractor-local.conf.js",
    "e2e-local-debugger": "npm run e2e-update && node --inspect-brk node_modules/protractor/bin/protractor ./e2e/protractor-local.conf.js",
    "e2e": "npm run e2e-update && npm run e2e-test",
    "e2e-test": "protractor ./e2e/protractor.conf.js",
    "e2e-update": "webdriver-manager update --standalone false --gecko false",
    "e2e-jenkins-staging": "npm run e2e-update && npm run e2e-staging",
    "e2e-jenkins-prod": "npm run e2e-update && npm run e2e-prod",
    "e2e-staging": "protractor ./e2e/protractor-staging.conf.js",
    "e2e-prod": "protractor ./e2e/protractor-prod.conf.js",
    "sonar": "sonar-scanner"
  },

标签: angularseleniumprotractor

解决方案


问题是因为 webdriver-manager 的本地和全局安装。

在 package.json 中创建一个 npm 脚本来更新 webdriver 管理器,例如

"wd:update": "webdriver-manager update"

这将在项目的 node_modules 中下载 webdriver-manager 的驱动程序和二进制文件。

从项目目录运行这个 npm 脚本 npm runwd:update


推荐阅读