DeprecationWarning:WindowsでPythonSeleniumとChromedriverを備えたBraveBrowserを使用して、chrome_optionsエラーの代わりにoptionsを使用する

Nov 27 2020

Windows 7 64にインストールされているPython(3.8)でSelenium(インストール済み:ver 3.141.0.dist-info)を使用したいのですが、Brave Browserバージョン1.17.73を使用していますChromium:87.0.4280.67(公式ビルド)(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

回答

1 DebanjanB Nov 27 2020 at 05:47

キー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")

参考文献

関連する詳細な説明がいくつかあります。

  • DeprecationWarning:Windows10システムでSeleniumを介してChromeDriverとChromeを使用してchrome_optionsエラーの代わりにオプションを使用する
  • WindowsでSeleniumとPythonを使用してBraveブラウザを開始する方法