My protractor.conf.js has the following content. I was unable to find out whats wrong here. I have manually created target/screenshots in my root folder of angular-cli. When i run protractor conf.js the protractor tests in browser window but the screenshots aren't being generated. Can anyone help me resolve this?
// Protractor configuration file
const { SpecReporter } = require('jasmine-spec-reporter');
var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var fs = require('fs');
var reporter = new HtmlScreenshotReporter({
dest: 'target/screenshots',
filename: 'my-report.html',
cleanDestination: false,
showSummary: true,
showConfiguration: false,
reportTitle: null,
ignoreSkippedSpecs: false,
captureOnlyFailedSpecs: false,
reportOnlyFailedSpecs: false
});
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: false,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
chromeOnly: true,
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(reporter);
},
afterLaunch: function(exitCode) {
return new Promise(function(resolve){
reporter.afterLaunch(resolve.bind(this, exitCode));
});
}
};
Thanks in Advance!
You can check by adding the 'protractor-screenshoter-plugin'
plugins: [{
package: 'protractor-screenshoter-plugin',
screenshotPath: <specify the path>,
screenshotOnExpect: 'failure',
screenshotOnSpec: 'failure+success',
withLogs: 'true',
writeReportFreq: 'asap',
imageToAscii: 'failure',
htmlReport:'true',
verbose:'info',
clearFoldersBeforeTest: true,
failTestOnErrorLog: {
failTestOnErrorLogLevel: 900
}
},
Can also check https://www.npmjs.com/package/protractor-screenshoter-plugin
protractor-jasmine2-screenshot-reporter
compatible with jasmine2
, so change to framework: 'jasmine2'
in your conf.js
And you need to use higher version of Protractor
which includes jasmine2
I did a quick test with your conf(did little changes) and it worked.
conf.js
var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
// var fs = require('fs');
var reporter = new HtmlScreenshotReporter({
dest: 'target/screenshots',
filename: 'my-report.html',
cleanDestination: false,
showSummary: true,
showConfiguration: false,
reportTitle: null,
ignoreSkippedSpecs: false,
captureOnlyFailedSpecs: false,
reportOnlyFailedSpecs: false
});
exports.config = {
allScriptsTimeout: 11000,
// specs: [
// './e2e/**/*.e2e-spec.ts'
// ],
capabilities: {
'browserName': 'chrome'
},
directConnect: false,
// baseUrl: 'http://localhost:4200/',
framework: 'jasmine2',
// chromeOnly: true,
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
jasmine.getEnv().addReporter(reporter);
},
afterLaunch: function(exitCode) {
return new Promise(function(resolve){
reporter.afterLaunch(resolve.bind(this, exitCode));
});
}
};
spec.js
describe('xxx', function(){
it('yyy', function(){
browser.get('https://angular.io/');
});
});
target/screenshots folder and HTML report,
(I run for twice, so there are two screenshots.)
- click the
yyy
will open the screenshot
protractor-jasmine2-screenshot-reporter
will create target/screenshots
folder if not exist, no need to create in advance.
Version I used:
protractor 5.3.0
protractor-jasmine2-screenshot-reporter 0.5.0