【问题标题】:How do I fix this error/warning in selenium?如何在 selenium 中修复此错误/警告?
【发布时间】:2021-06-14 16:20:52
【问题描述】:

我试图简单地打开和关闭一个网站并使用 Python3 和 Selenium 获取它的标题。

我的代码-

from selenium import webdriver

PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)

driver.get("https://www.techwithtim.net")
print(driver.title)
driver.close()

它运行成功,但确实在终端中显示这些错误/警告

DevTools listening on ws://127.0.0.1:3040/devtools/browser/7d22edc8-0e93-4498-a836-55e560ffc60b
[65744:16912:0614/221655.716:ERROR:device_event_log_impl.cc(214)] [22:16:55.716] Bluetooth: bluetooth_adapter_winrt.cc:1072 Getting Default Adapter failed.
[65744:16912:0614/221655.772:ERROR:device_event_log_impl.cc(214)] [22:16:55.773] USB: usb_device_handle_win.cc:1058 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)

有人可以帮忙吗? 注意 - 我已经安装了 python selenium 模块和 chromewebdriver

【问题讨论】:

  • 如果它“运行成功”我很困惑你想要完成什么?只是让错误消失?根据代码,确实是一个很奇怪的错误信息。
  • 我知道但仍然询问是否有任何解决方案,因为我在其他情况下看到它不会引发此错误
  • 您可能需要检查您正在运行的版本。 stackoverflow.com/a/63270005
  • 我使用的是 Google Chrome-Version 91.0.4472.106 (Official Build) (64-bit) 和 Chrome Webdriver - 91.0.4472.19 注意我使用的是 windows

标签: python selenium


【解决方案1】:

我的问题终于解决了。

添加这些更改解决了问题并删除了这些警告。

from selenium import webdriver

options = webdriver.ChromeOptions() 
options.add_experimental_option("excludeSwitches", ["enable-logging"])

PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(options=options , executable_path=PATH)

driver.get("https://www.techwithtim.net")
print(driver.title)
driver.close()

【讨论】:

  • 不显示错误和警告并不意味着问题已解决。
猜你喜欢
  • 2022-10-31
  • 2021-05-11
  • 2021-10-01
  • 1970-01-01
  • 2023-01-04
  • 2019-12-07
  • 1970-01-01
  • 1970-01-01
  • 2016-09-28
相关资源
最近更新 更多