【问题标题】:Selenium closes browser right after openingSelenium 在打开后立即关闭浏览器
【发布时间】:2021-11-07 14:54:33
【问题描述】:

我正在尝试使用 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:CONSOLE(1)] “[盾牌]:不能 请求屏蔽 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。

【问题讨论】:

  • 请分享您的代码!
  • 我的错,我自己意识到并添加了它
  • 您确定您使用的是正确版本的 chromedriver
  • 我使用的是最接近的匹配,但也尝试使用 chrome 驱动程序管理器“service = Service(ChromeDriverManager().install())”,结果相同。

标签: python windows selenium web-scraping brave


【解决方案1】:

首先,你是否安装了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()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-10
    • 1970-01-01
    • 2017-09-10
    • 2014-06-14
    • 1970-01-01
    • 2017-08-20
    • 2017-11-21
    • 2014-11-23
    相关资源
    最近更新 更多