大家好,我是第一次使用protractor-html-reporter,我能够轻松生成报告,但是我无法使用screenhot并在失败时在报告中使用它,请帮助我,因为我越来越空使用量角器执行配置文件时,获取null的原因未知。
Code of config.js file
var b=require('./node_modules/protractor/built/index')
var SpecReporter =require('./node_modules/jasmine-spec-reporter').SpecReporter
var jasmineReporters = require('./node_modules/jasmine-reporters');
var HTMLReport = require('./node_modules/protractor-html-reporter');
exports.config={
onPrepare: function() {
b.browser.waitForAngularEnabled(false);
var fs = require('./node_modules/fs-extra');
fs.emptyDir('./Test_results/HTML_Report/Screenshots/', function (err) {
console.log(err);
});
jasmine.getEnv().addReporter({
specDone: function(result) {
if (result.status == 'failed') {
browser.getCapabilities().then(function (caps) {
var browserName = caps.get('browserName');
browser.takeScreenshot().then(function (png) {
var stream = fs.createWriteStream('./Test_results/HTML_Report/Screenshots/' + browserName + '-' + result.fullName+ '.png');
stream.write(new Buffer(png, 'base64'));
stream.end();
});
});
}
}
});
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: './Test_results/XMLReport',
filePrefix: 'xmloutput'
}));
jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStacktrace: true
}
}));
},
onComplete: function() {
var browserName, browserVersion;
var capsPromise = browser.getCapabilities();
capsPromise.then(function (caps) {
browserName = caps.get('browserName');
browserVersion = caps.get('version');
testConfig = {
reportTitle: 'Test Execution Report',
outputPath: './Test_results/HTML_Report',
screenshotPath: './Test_results/HTML_Report/Screenshots',
testBrowser: browserName,
browserVersion: browserVersion,
modifiedSuiteName: false,
screenshotsOnlyOnFailure: true
};
new HTMLReport().from('./Test_results/XMLReport/xmloutput.xml', testConfig);
});
},
directConnect:true,
framework:'jasmine2',
specs:['./specs/homepage.spec.js'],
jasmineNodeOpts:{
defaultTimeoutInterval: 60000
},
params:{
url:'https://www.landsend.com/'
},
capabilities:{
browserName:'chrome',
chromeOptions:{
args:['--start-maximized','--disable-notifications']
}
}
}
**Please find console logs given below in which I am getting null**:-
DevTools listening on ws://127.0.0.1:63037/devtools/browser/1a24e7e7-6861-45a6-b6f0-00c2ef2821d9
Started
Jasmine started
null
F
Homepage Test Suite
× Should be able to verify Homepage Header logo
- Expected true to be false.
at homepage.verifylogo (D:\Backup_work\Protractor projects\Landsend_framework\pageobjects\homepage.pom.js:39:20)
at UserContext.<anonymous> (D:\Backup_work\Protractor projects\Landsend_framework\specs\homepage.spec.js:17:11)
at new ManagedPromise (C:\Users\keshav.dwivedi\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1077:7)
at ControlFlow.promise (C:\Users\keshav.dwivedi\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2505:12)
at TaskQueue.execute_ (C:\Users\keshav.dwivedi\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\Users\keshav.dwivedi\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\Users\keshav.dwivedi\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2974:25)
Failures:
1) Homepage Test Suite Should be able to verify Homepage Header logo
Message:
Expected true to be false.
Stack:
Error: Failed expectation
at homepage.verifylogo (D:\Backup_work\Protractor projects\Landsend_framework\pageobjects\homepage.pom.js:39:20)
at UserContext.<anonymous> (D:\Backup_work\Protractor projects\Landsend_framework\specs\homepage.spec.js:17:11)
at C:\Users\keshav.dwivedi\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:112:25
at new ManagedPromise (C:\Users\keshav.dwivedi\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1077:7)
at ControlFlow.promise (C:\Users\keshav.dwivedi\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2505:12)
at schedulerExecute (C:\Users\keshav.dwivedi\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:95:18)
at TaskQueue.execute_ (C:\Users\keshav.dwivedi\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\Users\keshav.dwivedi\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\Users\keshav.dwivedi\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2974:25)
1 spec, 1 failure
Finished in 28.342 seconds
**************************************************
* Failures *
**************************************************
1) Homepage Test Suite Should be able to verify Homepage Header logo
- Expected true to be false.
Executed 1 of 1 spec (1 FAILED) in 28 secs.
[13:46:46] I/launcher - 0 instance(s) of WebDriver still running
[13:46:46] I/launcher - chrome #01 failed 1 test(s)
[13:46:46] I/launcher - overall: 1 failed spec(s)
[13:46:46] E/launcher - Process exited with error code 1
请参考图片链接 Report Image