I am trying to log console errors in protractor like this
log output is in format
{
level: {
value: 900,
name: 'WARNING'
},
message: 'message',
timestamp: 1442090739962,
type: ''
}, {
level: {
value: 800,
name: 'INFO'
},
message: 'message',
timestamp: 1442090740723,
type: ''
}, {
level: {
value: 1000,
name: 'ERROR'
},
message: 'error message',
timestamp: 1442090740723,
type: ''
},
I want to catch only errors so i have written test like this
it('it should be detect console errors', function() {
browser.manage().logs().get('browser').then(function(browserLogs) {
// browserLogs is an array of objects with level and message fields
browserLogs.forEach(function(log) {
if (log.level.value > 900) { // it's an error log
console.log('Browser console error!');
console.log(log.message);
}
});
});
});
Problem is it's catching errors sometimes and sometimes not.
when i give wrong path to websocket and if there is an error then it is logging it. But When I give wrong path to ng-include
and if there is a 404 error
in console then it's not logging.
I am using firefox for testing. Is this console plugin browser dependent or what? Why it is showing different behaviour for console errors?