問題描述
我看到 chromedriver 可以輸出一個(gè)日志文件(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)
此頁面顯示了如何在直接執(zhí)行 exe 時(shí)進(jìn)行設(shè)置:
This page shows how to set this up when executing the exe directly:
chromedriver.exe --verbose --log-path=chromedriver.log
我不知道如何在 Protractor 中進(jìn)行設(shè)置
I cannot figure out how to set this up in Protractor however
我目前的protractor.conf.js
require('babel/register');
exports.config = {
framework: 'jasmine2',
seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar'
};
來自 @alecxe 的回答如下和 量角器的瀏覽器設(shè)置文檔 我嘗試添加以下內(nèi)容(有和沒有 --
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"
]
}
}
我還嘗試指定一個(gè)絕對(duì)路徑 (log-path=/chromedriver.log
),但也沒有用.
I also tried specifying an absolute path (log-path=/chromedriver.log
) which also didn't work.
推薦答案
您始終可以在一個(gè)單獨(dú)的進(jìn)程中啟動(dòng)您自己的 chromedriver 實(shí)例,并告訴 Protractor 連接到該實(shí)例.例如,如果您使用以下命令啟動(dòng) chromedriver:
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
然后你可以像這樣使用 Protractor 的配置文件:
Then you could use a configuration file for Protractor like so:
exports.config = {
seleniumAddress: 'http://localhost:9515',
capabilities: {
'browserName': 'chrome'
},
specs: ['example_spec.js'],
};
這篇關(guān)于如何訪問量角器測試的 chromedriver 日志的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!