最新版本的Chromedriver性能日志不起作用。

huangapple go评论104阅读模式
英文:

Performance logs for latest Chromedriver not working

问题

我过去使用以下代码记录我的网页抓取器的性能统计信息:

d = DesiredCapabilities.CHROME.copy()
# 日志
d['goog:loggingPref'] = {'performance':'ALL'}

但是在最新的更新之后,似乎无法使其正常工作。

现在我收到以下错误:

InvalidArgumentException: Message: invalid argument: log type 'performance' not found (Session info: chrome=114.0.5735.198)

关于在DesiredCapabilities中初始化性能日志记录的方式是否有任何改变?

英文:

I used to log the performance stats of my web scraper with:

d = DesiredCapabilities.CHROME.copy()
# logs
d['goog:loggingPref'] = {'performance':'ALL'}

But after the latest updates I can't seem to make it work.

logs = driver.get_log('performance')

Now I get the following error:

InvalidArgumentException: Message: invalid argument: log type 'performance' not found (Session info: chrome=114.0.5735.198)

Did anything change in some recent updates about the way I need to initialize the performance logging in DesiredCapabilities?

答案1

得分: 1

DesiredCapabilities 曾经被弃用,现在在 Selenium v4.10 中已移除。

解决方案

您需要使用 ChromeOptions 的一个实例,如下所示:

from selenium.webdriver.chrome.options import Options

options = Options()
options.set_capability('goog:loggingPrefs', {'performance': 'ALL'})
driver = Chrome(options=options)
英文:

DesiredCapabilities which was earlier deprecated, is now removed in Selenium v4.10.


Solution

You have to use an instance of ChromeOptions as follows:

from selenium.webdriver.chrome.options import Options

options = Options()
options.set_capability('goog:loggingPrefs', {'performance': 'ALL'})
driver = Chrome(options=options)

huangapple
  • 本文由 发表于 2023年7月14日 05:14:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76683279.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定