在尝试在保护器中执行 conf.js 文件时,所有工作文件都在生成从 xml 到未附加到 html 报告的 html 屏幕截图的报告。还有为什么默认执行 onprepare 和 onComplete 。想知道这些的实现。
任何澄清都将有助于相关的 github 源代码。
exports.config = {
framework: 'jasmine2',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
capabilities: {
browserName: 'chrome'
},
onPrepare: function () {
console.log('on prepared called');
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new . jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
//savePath: '.',
filePrefix: 'xmlresults.xml'
}));
},
onComplete: function() {
console.log('on complete called');
var browserName, browserVersion;
var capsPromise = browser.getCapabilities();
capsPromise.then(function (caps) {
browserName = caps.get('browserName');
browserVersion = caps.get('version');
platform = caps.get('platform');
var HTMLReport = require('protractor-html-reporter-2');
testConfig = {
reportTitle: 'Protractor Test Execution Report',
outputPath: './',
outputFilename: 'ProtractorTestReport',
screenshotPath: './screenshots',
testBrowser: browserName,
browserVersion: browserVersion,
modifiedSuiteName: false,
screenshotsOnlyOnFailure: true,
testPlatform: platform
};
new HTMLReport().from('xmlresults.xml', testConfig);
});
}
}