英文:
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论