MultiCapabilities 配置错误

MultiCapabilities configuration error

我在通过两个浏览器(Firefox 和 Chrome)使用 multiCapabilities 时遇到错误。 这是我的配置的摘录:

exports.config = {
  allScriptsTimeout: 11000,

  seleniumAddress: 'http://localhost:4444/wd/hub',

  baseUrl: 'http://localhost:4200',

  specs: [
    './e2e/features/*.ts'
  ],

  multiCapabilities: [
    {'browserName': 'chrome'},
    {'browserName': 'firefox'}
  ],

  directConnect: false,

  framework: 'custom',

  frameworkPath: require.resolve('serenity-js'),

  cucumberOpts: {
    compiler: "ts:ts-node/register",
    tags: [],                      // <string[]> (expression) only execute the features or scenarios with tags matching the expression
    strict: true,                  // <boolean> fail if there are any undefined or pending steps
    dryRun: false,                 // <boolean> invoke formatters without executing steps
    compiler: [],
    require: ['./e2e/steps/*.ts'],  // require step definition files before executing features
    format: ["pretty"] // <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable)
  },

  beforeLaunch: function() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
  },

  onPrepare: function () {
    browser.ignoreSynchronization = true;
    browser.driver.manage().window().setSize(1800, 1500);
  }

我的步骤文件的开头:

import { browser, element, by } from 'protractor';
import { binding, given, when, then } from "cucumber-tsflow";
import { CallbackStepDefinition } from 'cucumber';

报错,只有当运行两个浏览器同时存在时,才会出现这个:

[15:12:32] I/launcher - Running 2 instances of WebDriver
[15:12:36] I/testLogger -
------------------------------------

[15:12:36] I/testLogger - [chrome #11] PID: 12332
[chrome #11] Specs: C:\Users\JeanB\work_projects\dealflo-cwf-ux\e2e\features\footer-component.feature.ts
[chrome #11]
[chrome #11] (node:12332) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[chrome #11] [15:12:33] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[chrome #11] [15:12:36] I/runnerCli - Unexpected token import

[15:12:36] I/testLogger -

[15:12:36] E/launcher - Runner process exited unexpectedly with error code: 1
[15:12:36] I/launcher - 1 instance(s) of WebDriver still running
[15:12:37] I/testLogger -
------------------------------------

[15:12:37] I/testLogger - [firefox #01] PID: 14720
[firefox #01] Specs: C:\Users\JeanB\work_projects\dealflo-cwf-ux\e2e\features\footer-component.feature.ts
[firefox #01]
[firefox #01] (node:14720) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[firefox #01] [15:12:33] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[firefox #01] [15:12:37] I/runnerCli - Unexpected token import

[15:12:37] I/testLogger -

[15:12:37] E/launcher - Runner process exited unexpectedly with error code: 1
[15:12:37] I/launcher - 0 instance(s) of WebDriver still running
[15:12:37] I/launcher - chrome #11 failed with exit code: 1
[15:12:37] I/launcher - firefox #01 failed with exit code: 1
[15:12:37] I/launcher - overall: 2 process(es) failed to complete
[15:12:37] E/launcher - Process exited with error code 100

我正在使用带有 cucumber-js 1.3 的量角器 5.1.2 这是错误还是我的配置有问题?

我终于在 angular-cli github 中找到了一个线程。 Link to angular-cli issue 基本上,beforeLaunch 是 运行 一次,因此,如果将 multiCapabilities 与 angular-cli.

一起使用
require('ts-node').register({
   project: 'e2e/tsconfig.e2e.json'
});

需要移动到OnPrepare

如果您关注 link.

,您可以找到更多相关信息