MultiCapabilities配置错误

时间:2017-07-26 20:19:14

标签: angular protractor angular-cli end-to-end

将multiCapabilities与两个浏览器(Firefox和Chrome)一起使用时出错。 这是我配置的摘录:

@Component
public class HibernateListenersConfigurer {

    @Autowired
    private EntityManagerFactory entityManagerFactory;

    @Autowired
    private HibernateEntityListener listener;

    @PostConstruct
    public void registerListeners() {

        // here I see Deprecated warning !!! 
        final HibernateEntityManagerFactory hibernateEntityManagerFactory = (HibernateEntityManagerFactory) this.entityManagerFactory;
        final SessionFactoryImpl sessionFactoryImpl = (SessionFactoryImpl) hibernateEntityManagerFactory.getSessionFactory();
        final EventListenerRegistry registry = sessionFactoryImpl.getServiceRegistry().getService(EventListenerRegistry.class);
        registry.getEventListenerGroup(EventType.POST_COMMIT_UPDATE).appendListener(listener);   
    }

我的步骤文件的开头:

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';

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

1 个答案:

答案 0 :(得分:1)

我终于在angular-cli github中找到了一个帖子。 Link to angular-cli issue 基本上,beforeLaunch运行一次,因此,如果将multiCapabilities与angular-cli一起使用。

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

需要移至OnPrepare

如果您点击链接,可以找到更多相关信息。