Don't fail with the first browser error.

log all browser errors and then fail
This commit is contained in:
Mohsen Azimi
2015-01-30 13:53:49 -08:00
parent 05e36a0179
commit 157dc79e9f

View File

@@ -30,15 +30,20 @@ var driver = new webdriver.Builder().
function checkConsoleErros () { function checkConsoleErros () {
it('should not have any console errors', function (done) { it('should not have any console errors', function (done) {
driver.manage().logs().get('browser').then(function(browserLogs) { driver.manage().logs().get('browser').then(function(browserLogs) {
var errors = [];
browserLogs.forEach(function(log){ browserLogs.forEach(function(log){
if (log.level.value > 900) {
console.error('browser error message:', log.message);
}
// 900 and above is "error" level. Console should not have any errors // 900 and above is "error" level. Console should not have any errors
expect(log.level.value).not.to.be.greaterThan(900); if (log.level.value > 900) {
console.log('browser error message:', log.message);
errors.push(log);
}
}); });
expect(errors).to.be.empty;
done(); done();
}); });
}); });