Friday, September 25Be an Automation Engineer

Setting Logging preferences in protractor: loggingPrefs

There are different loggers and their log levels in protractor. Click here to read about loggers.

We can configure the logging levels in protraction configuration file.

  capabilities: {
    'browserName': 'chrome',
    'loggingPrefs': {
      'driver': 'WARNING',
      'server': 'WARNING',
      'browser': 'INFO'

Execute the below spec to capture the console log.

describe('Capture Console messages', function() {
  beforeEach(function() {

  afterEach(function() {
    browser.manage().logs().get('browser').then(function(browserLog) {
      if(browserLog.length > 0)
      console.log('log: ' + JSON.parse(JSON.stringify(browserLog))[0].message);

  it('This test should log a message into the browser console', function() {
    browser.executeScript(function() {console.log('This is from  browser console.')});


%d bloggers like this: