change how screenshot are captured

This commit is contained in:
Joe Fleming 2015-10-30 17:32:16 -07:00
parent 45bce9db2b
commit 22671d7a41
2 changed files with 24 additions and 13 deletions

View file

@ -18,13 +18,15 @@ define(function (require) {
.then(function (selected) {
expect(selected).to.be.ok();
})
.catch(common.handleError(this));
});
bdd.it('should load with name pattern unchecked', function () {
return settingsPage.getNameIsPatternCheckbox().isSelected()
.then(function (selected) {
expect(selected).to.not.be.ok();
});
})
.catch(common.handleError(this));
});
bdd.it('should contain default index pattern', function () {
@ -34,6 +36,7 @@ define(function (require) {
.then(function (pattern) {
expect(pattern).to.be(defaultPattern);
})
.catch(common.handleError(this));
});
bdd.it('should not select the time field', function () {
@ -41,13 +44,9 @@ define(function (require) {
.then(function (timeFieldIsSelected) {
common.log('timeField isSelected = ' + timeFieldIsSelected);
expect(timeFieldIsSelected).to.not.be.ok();
});
})
.catch(common.handleError(this));
});
// var testSubName = 'testSettingsInitialState';
// function screenshotError(reason) {
// return common.screenshotError(testSubName, reason);
// }
});
};
});

View file

@ -55,15 +55,27 @@ define(function (require) {
.then(function () { log('... sleep(' + sleepMilliseconds + ') end'); })
},
screenshotError: function screenshotError(testSubName, reason) {
handleError: function (testObj) {
var self = this;
var now = Date.now();
var filename = path.resolve('./screenshot-' + testSubName + '-ERROR-' + now + '.png');
self.log('Test Failed, taking screenshot "' + filename + '"');
return self.remote.takeScreenshot()
testName = (testObj.parent) ? [testObj.parent.name, testObj.name].join('_') : testObj.name;
return function (reason) {
var now = Date.now();
var filename = path.resolve(['./screenshot', now, testName, '.png'].join('_'));
return self.saveScreenshot(filename)
.then(function () {
throw new Error(reason);
})
};
},
saveScreenshot: function saveScreenshot(filename) {
this.log('Test Failed, taking screenshot "' + filename + '"');
return this.remote.takeScreenshot()
.then(function writeScreenshot(data) {
fs.writeFileSync(filename, data);
throw new Error(reason);
});
}
};