UMA*_*IYA 28 python selenium google-chrome selenium-chromedriver windows-10
我在 python 中运行 selenium webdriver 脚本时得到了这个我还在系统环境中设置了路径,并尝试下载与我的 chrome 版本匹配的 webdriver。而且也是letest版本。但我仍然收到此错误:
[8552:6856:1120/155118.770:ERROR:device_event_log_impl.cc(211)] [15:51:18.771] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[8552:6856:1120/155118.774:ERROR:device_event_log_impl.cc(211)] [15:51:18.774] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[8552:6856:1120/155118.821:ERROR:device_event_log_impl.cc(211)] [15:51:18.821] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
Run Code Online (Sandbox Code Playgroud)
我在我的代码中使用了这个:
driver = webdriver.Chrome(resource_path("C:\\webdriver\\chromedriver.exe")) # to open the chromebrowser
driver.get("https://web.whatsapp.com")
Run Code Online (Sandbox Code Playgroud)
小智 25
这是一个 chromedriver 问题,他们仍在解决问题。我不完全确定是什么原因造成的,但 Debanjan 的回答中似乎详细介绍了技术细节。
互联网上的一般解决方案似乎只是“忽略它”,但它确实使日志混乱很多。
不过,我确实找到了让它关闭的方法(以及经常弹出的“DevTools”警告)。
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=options)
Run Code Online (Sandbox Code Playgroud)
您还可以添加其他 chromedriver 选项并切换到该选项,此外还可以根据需要指向您的 chromedriver 可执行文件。
Deb*_*anB 10
这个错误信息...
[14432:11656:1120/161059.539:ERROR:device_event_log_impl.cc(211)] [16:10:59.539] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
Run Code Online (Sandbox Code Playgroud)
...暗示ChromeDriver在尝试启动/生成新的浏览上下文(即Chrome 浏览器会话)时引发错误。
出现此错误是由于USB设备连接到Windows-10系统并且无法正常运行。
此错误在usb_device_handle_win.cc 中定义如下:
void UsbDeviceHandleWin::GotDescriptorFromNodeConnection(
TransferCallback callback,
scoped_refptr<base::RefCountedBytes> request_buffer,
scoped_refptr<base::RefCountedBytes> original_buffer,
Request* request_ptr,
DWORD win32_result,
size_t bytes_transferred) {
std::unique_ptr<Request> request = UnlinkRequest(request_ptr);
if (win32_result != ERROR_SUCCESS) {
SetLastError(win32_result);
USB_PLOG(ERROR) << "Failed to read descriptor from node connection";
std::move(callback).Run(UsbTransferStatus::TRANSFER_ERROR, nullptr, 0);
return;
}
Run Code Online (Sandbox Code Playgroud)
此错误无害,也不会阻止新浏览上下文(即Chrome 浏览器会话)的产生。因此,您可以放心地忽略该错误。
然而,在你的代码块需要更换关键词 resource_path与executable_path你的有效的代码块将是:
webdriver.Chrome(executable_path=r'C:\webdriver\chromedriver.exe') # to open the chromebrowser
driver.get("https://web.whatsapp.com")
Run Code Online (Sandbox Code Playgroud)
您可以在以下位置找到一些相关的详细讨论:
小智 7
解决方案:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time
options = Options()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(executable_path=r"D:\SW\chromedriver90\chromedriver.exe",chrome_options=options)
url = 'https://carlsagan.com/'
driver.get(url)
...
driver.quit()
Run Code Online (Sandbox Code Playgroud)
在为我的错误找到了一个星期的答案后,我最终得到了一个解决方案,您只需要安装 pywin32 库,它就不会出现错误
打开cmd并输入
pip 安装 pywin32
你很高兴去......!
| 归档时间: |
|
| 查看次数: |
50844 次 |
| 最近记录: |