我计划将Protractor + Jasmin与Angular2 E2E测试用例一起使用,使用浏览器功能很好,但我真的需要看看Headless浏览器。据我所知,PhantomJS是使用Headless的唯一选择。但我真的不知道如何在Protractor中使用。目前My Protractor Conf文件如下所示
/*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.
答案 0 :(得分:1)
Error: browserName (phantomjs) is not supported with directConnect. at Direct.setupEnv
。
您需要从配置中删除directConnect
。这些选项仅在Chrome和Firefox上受支持。查看master config和server setup文档以获取更多信息。