iT邦幫忙

0

selenium 要怎麼 操作 Edge 報一堆錯

python 3 安裝 edge webdriver 有錯
DevTools listening on ws://127.0.0.1:62958/devtools/browser/115c7d16-d512-4c53-8fee-0afa6d96edb3
[25444:15112:0319/161417.523:ERROR:device_event_log_impl.cc(214)] [16:14:17.522] USB: usb_device_handle_win.cc:1056 Failed to read descriptor from node connection: 連結到系統的某個裝置失去作用。 (0x1F)
[25444:15112:0319/161417.524:ERROR:device_event_log_impl.cc(214)] [16:14:17.523] USB: usb_device_handle_win.cc:1056 Failed to read descriptor from node connection: 連結到系統的某個裝置失去作用。 (0x1F)
[25444:15112:0319/161417.525:ERROR:device_event_log_impl.cc(214)] [16:14:17.525] USB: usb_device_handle_win.cc:1056 Failed to read descriptor from node connection: 連結到系統的某個裝置失去作用。 (0x1F)
https://ithelp.ithome.com.tw/upload/images/20210319/201345291kn2pHN1yA.png

https://ithelp.ithome.com.tw/upload/images/20210319/20134529fI8MnSpbB4.png

看更多先前的討論...收起先前的討論...
照這篇做有問題呀
https://blog.csdn.net/qq_15031941/article/details/109493155
ccutmis iT邦高手 2 級 ‧ 2021-03-19 16:39:10 檢舉
這不是南北拳的問題
蝦米 看無 壓 大神救救我壓
也下載最新的了 89.0.077457 64 BIT
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

3
nwm310
iT邦新手 4 級 ‧ 2021-03-20 20:57:02
最佳解答

取消log

from msedge.selenium_tools import Edge,EdgeOptions
options = EdgeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])

https://stackoverflow.com/questions/64927909/failed-to-read-descriptor-from-node-connection-a-device-attached-to-the-system

請問 可以給比較完整的程式碼嗎? 下面的程式可以執行 但還是會報錯

from msedge.selenium_tools import Edge,EdgeOptions
driver_url = "msedgedriver.exe"
options = EdgeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
browser = Edge(executable_path=driver_url, options=options)
browser.get("http://www.baidu.com")
browser.save_screenshot('baidu.png')

nwm310 iT邦新手 4 級 ‧ 2021-03-22 19:24:57 檢舉

必須加一行

options.use_chromium = True

感謝 沒報奇怪的錯了 /images/emoticon/emoticon02.gif

2
fillano
iT邦超人 1 級 ‧ 2021-03-20 09:26:52

我照著範例跑(改成抓google首頁),雖然有錯誤訊息,但是網頁的圖有抓到:

D:\builds\selenium_edge>python test.py
[4676:9028:0320/091134.627:ERROR:storage_reserve.cc(164)] Failed to open file to mark as storage reserve: C:\Users\filla\AppData\Local\Temp\scoped_dir2868_946610133\Default\Code Cache\js

DevTools listening on ws://127.0.0.1:52768/devtools/browser/d7efeb53-c958-45b1-a50e-948d53c6d381
done

D:\builds\selenium_edge>dir
 磁碟區 D 中的磁碟是 新增磁碟區
 磁碟區序號:  D093-F9DF

 D:\builds\selenium_edge 的目錄

2021/03/20  上午 09:11    <DIR>          .
2021/03/20  上午 09:11    <DIR>          ..
2021/03/20  上午 09:11            59,894 google.png
2021/03/20  上午 09:02             1,133 test.py
               2 個檔案          61,027 位元組
               2 個目錄  1,943,729,930,240 位元組可用

抓到的網頁圖片:

https://ithelp.ithome.com.tw/upload/images/20210320/20000108PJt07BWbBi.png

如果拿掉程式最後一行的browser.quit(),錯誤訊息中的目錄(...scoped_dir2868_946610133...)就不會自動被刪掉,你可以打開看看,但是訊息一樣會出現。

我知道 可以執行 但那個報錯 應該就是異常
其他 CHROME FIREFOX 都不會有這個問題
這樣子還滿困擾的 

我要發表回答

立即登入回答