【问题标题】:DeprecationWarning: use options instead of chrome_options error using Brave Browser With Python Selenium and Chromedriver on Windows弃用警告:在 Windows 上使用带有 Python Selenium 和 Chromedriver 的 Brave 浏览器使用选项而不是 chrome_options 错误
【发布时间】:2023-03-28 17:18:01
【问题描述】:

我想在我的 Windows 7 64 上安装的 Python (3.8) 上使用 Selenium(安装:ver 3.141.0.dist-info), 我使用 Brave 浏览器版本 1.17.73 Chromium: 87.0.4280.67 (Official Build) (64-bit) 和

Chromedriver (chromedriver_win32-87.0.4280.20) 为它, 运行以下我从here 获取代码的 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

【问题讨论】:

    标签: python selenium selenium-webdriver selenium-chromedriver brave-browser


    【解决方案1】:

    密钥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")
    

    参考文献

    您可以在以下位置找到一些相关的详细讨论:

    【讨论】:

    • 感谢您的回复,我尝试了您的代码,但它仍然抛出错误,我猜同样的错误:其中一些:` c:/Users/mycomp/Desktop/Python/test/getwebdriver2. py [7088:9104:1127/022037.988:ERROR:os_crypt_win.cc(93)] 解密失败:参数错误。 (0x57) [7088:9104:1127/022037.990:ERROR:brave_sync_prefs.cc(114)] 解密同步种子失败 DevTools 监听 ws://127.0.0.1:53545/devtools/browser/288a869a-577c-400b-9ac7- 7f318174d272 [1127/022048.029:ERROR:gl_surface_egl.cc(773)] EGL 驱动程序消息(错误) eglQueryDeviceAttribEXT:属性错误。`
    • @Dave99 os_crypt_win.cc(93)] Failed to decrypt: The parameter is incorrect. 是一个不同的错误,很可能是 Brave Browser 回调问题,需要进一步详细调查。我确定您的DeprecationWarning 的缩写错误现在已解决。
    • @Dave99 如果我的answer满足了您的question,请点击空心处acceptanswer我的 answer 旁边的复选标记位于 votedown 箭头下方,因此复选标记变为 绿色
    • 我安装了新版本的 Chrome,尝试将 Selenium 与相同版本的 webdriver 一起使用,出现错误:GL Driver message (Error) 1127/130527.830:ERROR:gl_surface_egl.cc(773)] EGL Driver message (Error) eglQueryDeviceAttribEXT: Bad attribute. 也许我应该使用 Firefox,我使用 Brave 因为它速度快,我机器上的 Chrome 运行速度很慢。
    • 我正在阅读关于此Here 的帖子,如果它涉及调用 click() 或 send_keys() 使用一些代码块,但我只是加载 Web 浏览器进行测试,它是否涉及任何这些?使用任何代码块?我在我的 Windows 机器上安装了 python,这个仅限 ES2 的设备是否与它有任何关系?我认为这些 ES2 设备只是像移动设备这样的设备。
    猜你喜欢
    • 1970-01-01
    • 2020-01-10
    • 2020-10-18
    • 2021-06-26
    • 1970-01-01
    • 2022-01-15
    • 1970-01-01
    • 2018-11-15
    相关资源
    最近更新 更多