已解决Message: invalid argument: log type ‘performance‘ not found
已解决selenium模块利用performance获取network日志请求,抛出异常selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: log type ‘performance’ not found
报错问题
一个小伙伴遇到问题跑来私信我,想用selenium模块利用performance获取network日志请求,但是发生了报错(当时他心里瞬间凉了一大截,跑来找我求助,然后顺利帮助他解决了,顺便记录一下希望可以帮助到更多遇到这个bug不会解决的小伙伴),报错代码如下所示:
chrome_options = webdriver.ChromeOptions()
# chrome_options.add_argument("--disable-blink-features=AutomationControlled")
# chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
chrome_options.add_experimental_option('w3c', True)
caps = DesiredCapabilities.CHROME
caps['loggingPrefs'] = {'performance': 'ALL'}
driver = webdriver.Chrome(desired_capabilities=caps, options=chrome_options) #
driver.implicitly_wait(8)
driver.maximize_window()
driver.get(goods_url) #
# 获取network请求
logs = [json.loads(log['message'])['message'] for log in driver.get_log('performance')]
for log in logs:
print(log)
print('------------')
报错信息截图如下所示:
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: log type 'performance' not found
报错翻译
报错信息内容翻译如下所示:
selenium.mon.解释.无效参数异常:消息:无效参数:找不到日志类型“performance”
报错原因
报错原因如下:
使用caps['loggingPrefs'] = {'performance': 'ALL'}
监控network请求日志记录,但是新版selenium模块,改名了所以会提示找不到performance
。
小伙伴们按下面的方法修改代码即可解决!!!
解决方法
新版selenium模块将caps['loggingPrefs'] = {'performance': 'ALL'}
修改为下方代码即可:
caps["goog:loggingPrefs"] = {"performance": "ALL"}
再次运行代码成功了:
以上是此问题报错原因的解决方法,欢迎评论区留言讨论是否能解决,如果有用欢迎点赞收藏文章谢谢支持,博主才有动力持续记录遇到的问题!!!
千人全栈VIP答疑群联系博主帮忙解决报错
由于博主时间精力有限,每天私信人数太多,没办法每个粉丝都及时回复,所以优先回复VIP粉丝,可以通过订阅限时9.9付费专栏《100天精通Python从入门到就业》进入千人全栈VIP答疑群,获得优先解答机会(代码指导、远程服务),白嫖80G学习资料大礼包,专栏订阅地址:https://blog.csdn.net/yuan2019035055/category_11466020.html
-
优点:作者优先解答机会(代码指导、远程服务),群里大佬众多可以抱团取暖(大厂内推机会),此专栏文章是专门针对零基础和需要进阶提升的同学所准备的一套完整教学,从0到100的不断进阶深入,后续还有实战项目,轻松应对面试!
-
专栏福利:简历指导、招聘内推、每周送实体书、80G全栈学习视频、300本IT电子书:Python、Java、前端、大数据、数据库、算法、爬虫、数据分析、机器学习、面试题库等等
-
注意:如果希望得到及时回复,和大佬们交流学习,订阅专栏后私信博主进千人VIP答疑群
相关文章
- ERROR: invalid page header in block 27073 of relation base/21078/45300926
- R语言 启动报错 *** glibc detected *** /usr/lib64/R/bin/exec/R: free(): invalid next size (fast): 0x000000000263a420 *** 错误 解决方案
- Oracle 记录插入时“Invalid parameter binding ”错误
- 如何处理SAP OData错误消息: Invalid parametertype used at function XXXX
- mybatis部分版本异常invalid comparison: java.util.Date and java.lang.String
- 成功解决_catboost.CatBoostError: Invalid cat_features[4] = 8 value: index must be < 8.
- 成功解决Error:invalid character in identifier
- 成功解决(六种方法大总结)UnicodeDecodeError utf-8 codec cant decode byte 0xd0 in position 3150: invalid con
- 成功解决UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd3 in position 238: invalid continuation b
- 已解决OSError: [Errno 22] Invalid argument: ‘E:桌面x0c.txt‘
- 解决Property ‘spring.profiles.active‘ imported from location ‘application-xxx.yml‘ is invalid in...的问题
- 手机配置代理报错invalid host header
- RunHarmony() warning - Invalid name supplied, making object name syntactically valid
- 解决selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: invalid 'expiry'