You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Selenium+Python自动化报错:无法读取USB设备接口GUIDs求助

解决Selenium ChromeDriver USB日志报错问题

首先明确:你看到的这个USB相关报错属于ChromeDriver的非致命日志信息,不会影响表单填写代码的实际执行。先检查你的代码是否已经成功在表单中填入了"Test"——如果功能正常,这个报错可以忽略。

如果想要屏蔽这类日志输出,可通过配置ChromeOptions调整日志级别,修改后的代码如下:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

# 配置Chrome选项,过滤日志
chrome_options = Options()
# 设置日志级别为WARNING及以上,屏蔽INFO级别的USB日志
chrome_options.add_argument('--log-level=3')

web = webdriver.Chrome(options=chrome_options)
web.get('https://fs30.formsite.com/LB2014/wa03ei3cqi/index.html')

time.sleep(2)

FirstName = "Test"     
first = web.find_element('xpath', "//*[@id='RESULT_TextField-4']")
first.send_keys(FirstName)

额外优化建议

  • 避免使用time.sleep()这种固定等待,改用Selenium的显式等待,更稳定可靠:
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.common.by import By
    
    # 替换time.sleep(2)为:
    WebDriverWait(web, 10).until(
        EC.presence_of_element_located((By.XPATH, "//*[@id='RESULT_TextField-4']"))
    )
    

内容的提问来源于stack exchange,提问作者FiveO

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 14:25:22