问题
I have written below code in afterEach method to capture screenshot on failure
afterEach(function() {
var passed = jasmine.getEnv().currentSpec.results().passed();
if (!passed) {
browser.takeScreenshot().then(function(png) {
//capturing screenshot here
};
}
});
But while executing getting below error..
Message:
Failed: Cannot read property 'results' of undefined
Stack:
TypeError: Cannot read property 'results' of undefined
how to remove above error...
回答1:
currentSpec
is not going to work with jasmine2
.
Please see if protractor-jasmine2-screenshot-reporter fits your use case.
There is also jasmine-test-container-support library that extends jasmine2 and provides you with all of the meta information you would need about the currently executed test.
来源:https://stackoverflow.com/questions/34393988/protractor-capture-screenshot-on-failure