簡體   English   中英

棄用警告:在 Python Selenium 和 Windows 上使用 Brave 瀏覽器時使用選項而不是 chrome_options 錯誤

[英]DeprecationWarning: use options instead of chrome_options error using Brave Browser With Python Selenium and Chromedriver on Windows

I want to use Selenium (installed: ver 3.141.0.dist-info) on Python (3.8) which is installed on my Windows 7 64, I Use Brave Browser Version 1.17.73 Chromium: 87.0.4280.67 (Official Build) (64 -位)和

Chromedriver(chromedriver_win32-87.0.4280.20),當運行我從這里獲取代碼的以下 Py 文件時,新的 Brave 瀏覽器打開,但出現錯誤。

有什么解決方案可以使它起作用嗎? 感謝你的幫助。

運行此文件時:

from selenium import webdriver
driver_path = 'C:/python/Python38/chromedriver.exe'
brave_path = 'C:/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'
option = webdriver.ChromeOptions()
option.binary_location = brave_path
browser = webdriver.Chrome(executable_path=driver_path, chrome_options=option)

browser.get("https://www.google.es")

得到這些錯誤:

c:/Users/mycomp/Desktop/Python/test/getwebdriver.py:12: DeprecationWarning: use options instead of 
chrome_options
browser = webdriver.Chrome(executable_path=driver_path, chrome_options=option)
[7132:3952:1127/003249.595:ERROR:os_crypt_win.cc(93)] Failed to decrypt: The parameter is incorrect. 
(0x57)
[7132:3952:1127/003249.596:ERROR:brave_sync_prefs.cc(114)] Decrypt sync seed failure

DevTools listening on ws://127.0.0.1:51576/devtools/browser/a048c130-e608-4ec6-a388-ad67fc32d97a
[1127/003250.360:ERROR:gl_surface_egl.cc(773)] EGL Driver message (Error) eglQueryDeviceAttribEXT: 
Bad attribute.
[1127/003250.452:ERROR:gl_surface_egl.cc(773)] EGL Driver message (Error) eglQueryDeviceAttribEXT: 
Bad attribute.
[1127/003250.455:ERROR:gl_surface_egl.cc(773)] EGL Driver message (Error) eglQueryDeviceAttribEXT: 
Bad attribute.
[1127/003250.457:ERROR:gl_surface_egl.cc(773)] EGL Driver message (Error) eglQueryDeviceAttribEXT: 
Bad attribute.
[1127/003250.458:ERROR:gl_surface_egl.cc(773)] EGL Driver message (Error) eglQueryDeviceAttribEXT: 
Bad attribute.
[1127/003250.711:ERROR:gl_surface_egl.cc(773)] EGL Driver message (Error) eglQueryDeviceAttribEXT: 
Bad attribute.
[1127/003250.821:ERROR:gl_surface_egl.cc(773)] EGL Driver message (Error) eglQueryDeviceAttribEXT: 
Bad attribute.
[1127/003252.062:ERROR:gl_surface_egl.cc(773)] EGL Driver message (Error) eglQueryDeviceAttribEXT: 
Bad attribute.
[1127/003254.498:ERROR:gl_surface_egl.cc(773)] EGL Driver message (Error) eglQueryDeviceAttribEXT: 
Bad attribute.

C:\Users\mycomp\Desktop\Python\test>[1127/003304.647:ERROR:gl_surface_egl.cc(773)] EGL Driver message 
(Error) eglQueryDeviceAttribEXT: Bad attribute.

編輯:

我從另一個地方找到了解決方案,將以下內容添加到代碼中,但我仍然收到錯誤,錯誤更少

option.add_argument('--disable-gpu')

我運行它並收到此錯誤:

c:/Users/mycomp/Desktop/Python/test/getwebdriver.py:12: DeprecationWarning: 
use options instead of chrome_options
browser = webdriver.Chrome(executable_path=driver_path, 
chrome_options=option)
[6208:8532:1127/021046.062:ERROR:os_crypt_win.cc(93)] Failed to decrypt: The 
parameter is incorrect. (0x57)
[6208:8532:1127/021046.063:ERROR:brave_sync_prefs.cc(114)] Decrypt sync seed 
failure

DevTools listening on ws://127.0.0.1:53262/devtools/browser/adb0a87d-298a- 
4b9c-ad00-132a607cb9bd

%20%20browser-with-python-selenium-and-chromedriver

chrome_options在某個時候被棄用了。 相反,您必須使用options ,您的有效代碼塊將是:

from selenium import webdriver

driver_path = 'C:/python/Python38/chromedriver.exe'
brave_path = 'C:/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'
option = webdriver.ChromeOptions()
option.binary_location = brave_path
browser = webdriver.Chrome(executable_path=driver_path, options=option)

browser.get("https://www.google.es")

參考

您可以在以下位置找到一些相關的詳細討論:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM