【问题标题】:Protractor+Jasmin with angular2 E2E testcasesProtractor+Jasmine 与 Angular 2 E2E 测试用例
【发布时间】:2016-07-22 19:59:57
【问题描述】:

我计划将 Protractor + Jasmin 与 Angular2 E2E 测试用例一起使用,使用浏览器功能很好,但我确实需要查看无头浏览器。据我所知,PhantomJS 是使用 Headless 的一种选择。但是我真的不知道如何在量角器中进行配置。目前我的量角器配置文件如下所示

/*global jasmine */
var SpecReporter = require('jasmine-spec-reporter')

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    '../e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {

    'browserName': 'chrome',
    /*browserName: 'phantomjs',
       version: '',
       platform: 'ANY'*/
  },
  directConnect: true,
  baseUrl: 'http://localhost:8080/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },
  useAllAngular2AppRoots: true,
  beforeLaunch: function() {
    require('ts-node').register({
      project: 'e2e'
    });
  },
  onPrepare: function() {
    jasmine.getEnv().addReporter(new SpecReporter());
  }
}

如何在不打开浏览器的情况下配置 PhantomJS?我想这在所有用于部署的 CDCI PIPE 行中最有用

为此添加:我为 phantomJS 添加了以下代码。

 capabilities: {

    //'browserName': 'chrome',
    browserName: 'phantomjs',
    'phantomjs.binary.path': 'dist/vendor/phantomjs/bin/phantomjs',
    'phantomjs.ghostdriver.cli.args': ['--loglevel=DEBUG']

  },

当我使用 ng e2e 运行量角器时,我收到以下错误:

Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.

> recoveries-app@0.0.0 pree2e /Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app
> webdriver-manager update

selenium standalone is up to date.
chromedriver is up to date.

> recoveries-app@0.0.0 e2e /Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app
> protractor "config/protractor.conf.js"

[16:49:27] E/launcher - Process exited with error code 1


/Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app/node_modules/protractor/built/driverProviders/direct.js:39
                throw new Error('browserName (' + this.config_.capabilities.browserName +
                      ^
Error: browserName (phantomjs) is not supported with directConnect.
    at Direct.setupEnv (/Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app/node_modules/protractor/built/driverProviders/direct.js:39:23)
    at Runner.run (/Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app/node_modules/protractor/built/runner.js:252:37)
    at TaskRunner.run (/Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app/node_modules/protractor/built/taskRunner.js:108:27)
    at createNextTaskRunner (/Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app/node_modules/protractor/built/launcher.js:208:28)
    at /Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app/node_modules/protractor/built/launcher.js:235:13
    at _fulfilled (/Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app/node_modules/protractor/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (/Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app/node_modules/protractor/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (/Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app/node_modules/protractor/node_modules/q/q.js:796:13)
    at /Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app/node_modules/protractor/node_modules/q/q.js:604:44
    at runSingle (/Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app/node_modules/protractor/node_modules/q/q.js:137:13)

npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "e2e" "--" "config/protractor.conf.js"
npm ERR! node v4.4.5
npm ERR! npm  v2.15.5
npm ERR! code ELIFECYCLE
npm ERR! recoveries-app@0.0.0 e2e: `protractor "config/protractor.conf.js"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the recoveries-app@0.0.0 e2e script 'protractor "config/protractor.conf.js"'.
npm ERR! This is most likely a problem with the recoveries-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     protractor "config/protractor.conf.js"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs recoveries-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls recoveries-app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/nai628/BalaRequiredfiles/AngularCLIPOC/RecoveryProjectWorkSpaceUpdate_v1/customer-servicing-service/recoveries-app/npm-debug.log

Some end-to-end tests failed, see above.

【问题讨论】:

  • 添加上述内容:我尝试添加如下:
  • Error: browserName (phantomjs) is not supported with directConnect. at Direct.setupEnv 。从您的配置中删除 directConnect
  • @Gunderson 我认为您应该将其作为答案。谢谢。

标签: angularjs jasmine phantomjs protractor angular-cli


【解决方案1】:

Error: browserName (phantomjs) is not supported with directConnect. at Direct.setupEnv

您需要从配置中删除 directConnect。这些选项仅在 Chrome 和 Firefox 上受支持。查看master configserver setup 文档了解更多信息。

【讨论】:

  • 非常感谢根据您的建议问题得到了解决。我已经从 conf 文件中注释了 directConnect 并以全局方式安装 Phantomjs
  • @BalakrishnaTirumalasetti 没问题,很高兴它有帮助。请参阅此文档:stackoverflow.com/help/someone-answers
猜你喜欢
  • 2020-06-10
  • 1970-01-01
  • 2016-10-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-22
  • 2018-01-31
  • 2020-07-06
相关资源
最近更新 更多