How to access chromedriver logs for Protractor test

后端 未结 7 1129
一整个雨季
一整个雨季 2021-02-15 16:42

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 e

7条回答
  •  清酒与你
    2021-02-15 17:28

    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}" "$@"
    

提交回复
热议问题