How to access chromedriver logs for Protractor test How to access chromedriver logs for Protractor test google-chrome google-chrome

How to access chromedriver logs for Protractor test


You can always start up your own instance of chromedriver in a separate process and tell Protractor to connect to that. For example, if you start chromedriver with:

chromedriver --port=9515 --verbose --log-path=chromedriver.log

Then you could use a configuration file for Protractor like so:

   exports.config = {     seleniumAddress: 'http://localhost:9515',     capabilities: {       'browserName': 'chrome'     },     specs: ['example_spec.js'],   };


We use a shell script to add chromedriver logging, among other checks. You can then point protractor at the shell script:

protractor config:

// When running chromedriver, use this script:chromeDriver: path.resolve(topdir, 'bin/protractor-chromedriver.sh'),

bin/protractor-chromedriver.sh

TMPDIR="/tmp"NODE_MODULES="$(dirname $0)/../node_modules"CHROMEDRIVER="${NODE_MODULES}/protractor/selenium/chromedriver"LOG="${TMPDIR}/chromedriver.$$.log"fatal() {    # Dump to stderr because that seems reasonable    echo >&2 "$0: ERROR: $*"    # Dump to a logfile because webdriver redirects stderr to /dev/null (?!)    echo >"${LOG}" "$0: ERROR: $*"    exit 11}[ ! -x "$CHROMEDRIVER" ] && fatal "Cannot find chromedriver: $CHROMEDRIVER"exec "${CHROMEDRIVER}" --verbose --log-path="${LOG}" "$@"


According to the protractor's source code, chromedriver service is started without any arguments and there is no direct way to configure the arguments. Even though the chromedriver's Service Builder that protractor uses actually has an ability to specify the verbosity and the log path:

var service = new chrome.ServiceBuilder()    .loggingTo('/my/log/file.txt')    .enableVerboseLogging()    .build();

Old (incorrect) answer:

You need to set the chrome arguments:

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

See also: