如何访问Protroctor测试的chromedriver日志 [英] How to access chromedriver logs for Protractor test
问题描述
我看到chromedriver可以输出日志文件( https:// sites .google.com / a / chromium.org / chromedriver / logging )
I have seen that chromedriver can output a logfile (https://sites.google.com/a/chromium.org/chromedriver/logging)
此页面显示了在直接执行exe时如何设置:
This page shows how to set this up when executing the exe directly:
chromedriver.exe --verbose --log-path = chromedriver.log
我无法弄清楚如何在Protractor中设置它
I cannot figure out how to set this up in Protractor however
我当前的 protractor.conf.js
My current protractor.conf.js
require('babel/register');
exports.config = {
framework: 'jasmine2',
seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar'
};
来自 @ alecxe的回答和量角器的浏览器设置文档我尝试添加以下内容(有和没有 -
s)但没有明显效果:
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"
]
}
}
我也试过指定一个绝对路径( log-path = / chromedriver.log
),这也没用。
I also tried specifying an absolute path (log-path=/chromedriver.log
) which also didn't work.
推荐答案
我们使用shell脚本添加chromedriver日志记录以及其他检查。然后你可以在shell脚本上指出量角器:
We use a shell script to add chromedriver logging, among other checks. You can then point protractor at the shell script:
// When running chromedriver, use this script:
chromeDriver: path.resolve(topdir, 'bin/protractor-chromedriver.sh'),
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}" "$@"
这篇关于如何访问Protroctor测试的chromedriver日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!