Sometimes we need to get browser console information to validate tests. Protractor has ablity to retrieve the console info.
Need to add LoggingPrefs into config file and then you can access browser console info as per below code.
config:
Code:
Need to add LoggingPrefs into config file and then you can access browser console info as per below code.
config:
'browserName': 'chrome', name: 'chrome-scripts', count: 1, loggingPrefs: { "driver": "INFO", "browser": "INFO" }
Code:
browser.manage().logs().get('browser').then(function(browserLog) { console.log('No of info from console:' + browserLog.length); browserLog.forEach(function(logInfo){ console.log('browser console info: ' + require('util').inspect(logInfo)); consoleInfo = require('util').inspect(logInfo); if (consoleInfo.indexOf('name:') !== -1) { expect(consoleInfo).toContain(fileToUpload); } else if (consoleInfo.indexOf('size:') !== -1) { expect(consoleInfo).toContain(fileSizeInBytes); } }); });
No comments:
Post a Comment