我打算使用Protractor + Jasmin和Angular2 E2E測試案例,這很好用瀏覽器功能,但我真的需要看到無頭瀏覽器。據我所知,PhantomJS是使用無頭的選項之一。但我真的不知道如何配置量角器。目前我的量角器配置文件如下所示量角器+ Jasmin with angular2 E2E測試案例
/*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.
> [email protected] 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.
> [email protected] 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! [email protected] e2e: `protractor "config/protractor.conf.js"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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.
添加以上內容:我嘗試添加如下: –
錯誤:browserName(phantomjs)不支持directConnect。在Direct.setupEnv'。從配置中刪除'directConnect'。 – Gunderson
@Gunderson我認爲你應該把它作爲答案。謝謝。 – alecxe