在 python + selenium + pytest 执行自动化测试时候,遇到如下报错:
[25612:15512:0220/162104.300:ERROR:device_event_log_impl.cc(211)] [16:21:04.299] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection:
连到系统上的设备没有发挥作用。 (0x1F)
目前没找到原因,只能暴力解决:
在启动 Chrome 时候添加 options 如下:
option = webdriver.ChromeOptions()
# 防止打印一些无用的日志
option.add_experimental_option("excludeSwitches", ['enable-automation', 'enable-logging'])
driver = webdriver.Chrome(chrome_options=option)
原文链接:https://blog.csdn.net/liangjw99/article/details/113886367
补充
针对这一条语句
driver = webdriver.Chrome(chrome_options=option)
对于chrome浏览器来说,chrome_options=option
,最好写成options=option
,即:
driver = webdriver.Chrome(options=option)
要不然就会在terminal看到
DeprecationWarning: use options instead of chrome_options
driver = webdriver.Chrome(chrome_options=option)