gpt4 book ai didi

javascript - 如何用 selenium 更改 phantomjs 的日志文件路径?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:43:52 26 4
gpt4 key购买 nike

当将 phantomjs 与 selenium 一起使用时,我想更改默认的 --webdriver-logfile 参数,该参数将 selenium 传递给 phantomjs。我该怎么做?

selenium日志中对应的行:

11:06:06.960 INFO - arguments: [--webdriver=14380, --webdriver-logfile=<ROOT PATH DELETED HERE>/phantomjsdriver.log]

在 coffeescript 中启动 phantomjs:

webdriverio = require 'webdriverio'

module.exports.World = World = (next) ->
@browser = webdriverio.remote({ desiredCapabilities: {
browserName: 'phantomjs'
"phantomjs.binary.path": "node_modules/phantomjs/bin/phantomjs"
}})
.init()

next()

最佳答案

我找了几个小时都找不到答案,因此我在 selenium 调用的 phantomjs 文件中破解了它。这不是一个合适的解决方案,但可以完成工作。

args = args.map(function(str) {
if(str.search('-webdriver-logfile') != -1 ) {
console.log('Replacing default webdriver log with null in phantomjs');
return str.replace(/--webdriver-logfile=.*$/i,"--webdriver-logfile=/dev/null")
}
return str;
});

关于javascript - 如何用 selenium 更改 phantomjs 的日志文件路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25804745/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com