簡體   English   中英

Selenium 打開后立即關閉瀏覽器

[英]Selenium closes browser right after opening

我正在嘗試使用 Selenium(在 Python 中)打開 Brave。 它實際上打開但隨后立即關閉,控制台中出現以下錯誤:

[23340:9252:1107/063438.209:ERROR:os_crypt_win.cc(93)] 解密失敗:參數不正確。 (0x57) [23340:9252:1107/063438.210:ERROR:brave_sync_prefs.cc(114)] 解密同步種子失敗

DevTools 監聽 ws://127.0.0.1:53809/devtools/browser/ecce3b0e-2884-4173-bdab-2215a3d7f507 [23340:9252:1107/063438.480(ERROR:ERROR:CONSOLE)]為 tabId 請求屏蔽面板數據:2。錯誤:未指定標簽 URL”,來源:chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/out/brave_extension_background.bundle.js (1)

我做了一些搜索,但找不到任何有用的東西。

這是我的代碼:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

class Selen:
    def __init__(self):
        options = Options()
        service = Service("C:/Auxiliary/chromedriver_win32/chromedriver.exe")
        options.binary_location = "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
        self.driver = webdriver.Chrome(service=service, options=options)
        self.driver.get("https://google.com")

Selen()

我正在使用 Windows 11。

首先,您是否安裝了 chrome,其次,如果您這樣做,它是否有效?

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

class Selen:
    def __init__(self):
        options = Options()
        path = "C:/Auxiliary/chromedriver_win32/chromedriver.exe"
        self.driver = webdriver.Chrome(executable_path=path, options=options)
        self.driver.get("https://google.com")
        time.sleep(20)
        driver.close()

instance = Selen()

如果它確實有效,試試這個讓它勇敢地工作,

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

class Selen:
    def __init__(self):
        options = Options()
        options.binary_location = "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
        path = "C:/Auxiliary/chromedriver_win32/chromedriver.exe"
        self.driver = webdriver.Chrome(executable_path=path, options=options)
        self.driver.get("https://google.com")
        time.sleep(20)
        driver.close()

instance = Selen()

暫無
暫無

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

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