angular - 使用 Protractor 和 Angular 4 运行 E2E 测试

标签 angular protractor

我试图为我拥有的一个 Angular 4 项目运行一些 e2e 测试!

我遇到了一些无法解决的错误!

这是错误消息:

/usr/local/bin/node /Users/jothi/Books/Angular/ng-book-_The_Complete_Guide_to_Angular_4_-_basic_package/ng-book-code/http/node_modules/protractor/bin/protractor /Applications/WebStorm.app/Contents/plugins/JavaScriptLanguage/helpers/protractor-intellij/lib/protractor-intellij-config.js --intellijOriginalConfigFile=/Users/jothi/Books/Angular/ng-book-_The_Complete_Guide_to_Angular_4_-_basic_package/ng-book-code/http/protractor.conf.js --disableChecks
(node:63426) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[19:38:44] I/launcher - Running 1 instances of WebDriver
[19:38:44] I/direct - Using ChromeDriver directly...
[19:38:44] E/direct - Error code: 135
[19:38:44] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
[19:38:44] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.

有人可以告诉我问题到底是什么以及如何解决吗?

我从 WebStorm IDE 中运行它!

编辑:这是我的 protractor.conf 文件:

// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts

const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': 'chrome'
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },
  beforeLaunch: function() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
  },
  onPrepare() {
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  }
};

最佳答案

在运行测试之前尝试使用 webdriver-manager 下载 chromedriver:

"scripts": {
    "pretest": "webdriver-manager update",
    "test": "protractor protractor.conf.js",
},

然后在 package.json 文件所在的文件夹中使用终端命令运行 -

npm 测试

这将安装 ChromeDriver 并运行测试

关于angular - 使用 Protractor 和 Angular 4 运行 E2E 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45823932/

相关文章:

angular - Ionic Firebase Promise,每次更改值时调用一个函数

angularjs - 测试前端时重置单独的后端服务

javascript - Protractor 中的元素加载问题

javascript - Protractor + Jasmine : Run same test in parallel with different data inputs

angular - "ng generate universal"和 "ng add @nguniversal/express-engine"有什么区别?

javascript - 如何使用 Angular 2 在 *ngFor 列表中显示被点击的元素隐藏其他元素

javascript - 如何处理 Angular 2 中的文件版本

css - 在 Angular 7 中注入(inject)的 html 中分配 css 类

testing - 在 Protractor 辅助函数上,我如何知道 browser.get 是否被调用过?

jasmine - 我在哪里可以找到 Jasmine 期望的所有内置匹配器的列表