Avertissement: utiliser des options au lieu de l'erreur chrome_options en utilisant Brave Browser avec Python Selenium et Chromedriver sous Windows

Nov 27 2020

Je veux utiliser Selenium (installé: ver 3.141.0.dist-info) sur Python (3.8) qui est installé sur mon Windows 7 64, j'utilise Brave Browser Version 1.17.73 Chromium: 87.0.4280.67 (version officielle) (64 -bit) et

Chromedriver (chromedriver_win32-87.0.4280.20) pour cela, lors de l'exécution du fichier Py suivant dont j'ai obtenu le code d' ici , le nouveau navigateur Brave s'ouvre, mais j'obtiens des erreurs.

Une solution pour que cela fonctionne? Apprécier ton aide.

lors de l'exécution de ce fichier:

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

obtenez ces erreurs:

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.

Édité:

J'ai trouvé une solution à cela d'un autre endroit, pour ajouter ce qui suit au code, mais j'obtiens toujours des erreurs, moins d'erreurs

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

Je l'exécute et j'ai cette erreur:

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-avec-python-sélénium-et-chromedriver

Réponses

1 DebanjanB Nov 27 2020 at 05:47

La clé chrome_optionsétait obsolète il y a quelque temps. Au lieu de cela, vous devez utiliser optionset votre bloc de code efficace sera:

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

Les références

Vous pouvez trouver quelques discussions détaillées pertinentes dans:

  • Avertissement: utiliser des options au lieu de l'erreur chrome_options en utilisant ChromeDriver et Chrome via Selenium sur le système Windows 10
  • Comment lancer le navigateur Brave à l'aide de Selenium et Python sur Windows