sdnts
sdnts

Reputation: 728

Get chrome logs in WebdriverIO

I'm trying to get Chrome's logs when launched through WebdriverIO. These are the options I use in WebdriverIO:

{
      desiredCapabilities: {
        browserName: 'chrome',
        chromeOptions: {
          binary: path.resolve('/usr/bin/google-chrome'),
          args: [
            '--load-and-launch-app=' + path.resolve('./build/chrome/'),
            '--enable-logging',
            '--v=1',
            '--no-sandbox',
          ]
        }
      }
    }
}

The browser (and the extension) is launched properly, but I can't find the chrome_deug.log file in ~/.config/google-chrome/ folder.

However, if I Do this manually, as in, launching chrome from the terminal (google-chrome --enable-logging --v=1), the log file does appear. This leads me to believe I'm either doing something wrong or this is an issue with WebdriverIO.

I'm on Ubuntu 14.04, using Chrome 48, but I've noticed the same thing on OSX with Chrome 49 too.

Can someone point me in the right direction? Thanks.

Upvotes: 2

Views: 3382

Answers (1)

Jovan Kostovski
Jovan Kostovski

Reputation: 85

You can get the browser logs in your tests with the .log webdriver-io function:

browser.log('browser')

The important thing is that the .log function call clears the browser log so if you want to have the complete log you need to concatenate the results from the .log function. I do this like this:

this.browserLog = this.browserLog.concat(browser.log('browser').value);

Upvotes: 1

Related Questions