【问题标题】:Running E2E Tests with Protractor and Angular 4使用 Protractor 和 Angular 4 运行 E2E 测试
【发布时间】:2018-01-31 02:41:01
【问题描述】:

我正在尝试为我拥有的 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 } }));
  }
};

【问题讨论】:

  • 你想在浏览器或代码中运行它们?

标签: angular protractor


【解决方案1】:

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

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

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

npm test

这将安装 ChromeDriver 并运行测试

【讨论】:

    【解决方案2】:

    directConnect: true, 在你的 protractor.cong.js 中直接运行你的测试用例而不是使用 webdriver!

     ....
     capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
        'args': ['--no-sandbox', '--test-type=browser'],
        'prefs': {
          'download': {
            'prompt_for_download': false,
            'default_directory': 'C:/Temp'
          }
        }
    }
      },
      directConnect: true,
      baseUrl: conf.baseUrl,
      framework: 'jasmine',
      jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        print: function() {}
      },
      ...
    

    【讨论】:

    • 不!即使将 directConnect 设置为 true,它也不起作用!
    • 你使用的node、npm和protractor是什么版本?
    • Joes-MacBook-Pro:http jothi$ node --version v8.1.4
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-10
    相关资源
    最近更新 更多