How to access chromedriver logs for Protractor tes

2019-04-07 01:45发布

I have seen that chromedriver can output a logfile (https://sites.google.com/a/chromium.org/chromedriver/logging)

This page shows how to set this up when executing the exe directly:

chromedriver.exe --verbose --log-path=chromedriver.log

I cannot figure out how to set this up in Protractor however

My current protractor.conf.js

require('babel/register');

exports.config = {
    framework: 'jasmine2',
    seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar'
};

From @alecxe's answer below and protractor's browser setup docs I tried adding the following (with and without --s) but with no apparent effect:

    capabilities: {
        browserName: "chrome",
        chromeOptions: {
            args: [
                "--verbose",
                "--log-path=chromedriver.log"
            ]
        }
    }

I also tried specifying an absolute path (log-path=/chromedriver.log) which also didn't work.

7条回答
叛逆
2楼-- · 2019-04-07 02:43

I'm using this as a global afterEach hook (mocha):

afterEach(() => {
    browser.manage().logs().get('browser').then(function(browserLog) {
        if(browserLog && browserLog.length) {
            console.log('\nlog: ' + util.inspect(browserLog) + '\n');
        }
    });
});
查看更多
登录 后发表回答