是否有适用于Brave浏览器的Selenium驱动?能否用ChromeDriver适配Brave?
Absolutely—this is totally doable, and it’s a smart move to leverage Brave’s built-in shields instead of maintaining all that custom interceptor code. Since Brave is built on Chromium (just like Chrome), ChromeDriver is fully compatible with it, though you’ll need a few key configuration tweaks to get everything working right.
Step 1: Match ChromeDriver Version to Brave’s Chromium Kernel
First, make sure your ChromeDriver version aligns with the Chromium version underpinning your Brave installation. Here’s how to check:
- Open Brave, go to
Settings > About Brave - You’ll see a line like
Brave is up to date. Version 1.68.120 Chromium: 127.0.6533.72 (Official Build) (64-bit) - Download the ChromeDriver version that matches the Chromium number (in this case, 127.0.6533.72)
Step 2: Point ChromeDriver to Brave’s Executable
By default, ChromeDriver looks for Chrome’s binary—you need to tell it to use Brave instead. Here’s a quick example with Selenium in Python:
from selenium import webdriver from selenium.webdriver.chrome.options import Options # Set up options brave_options = Options() # Update this path to match your system's Brave installation # Windows example: "C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe" # Linux example: "/usr/bin/brave-browser" brave_options.binary_location = "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser" # Initialize the driver with Brave's options driver = webdriver.Chrome(options=brave_options) driver.get("https://example.com")
Step 3: Ensure Brave’s Built-In Interceptors Are Active
Brave’s Shields (its suite of ad/tracker/popup/image blockers) are usually enabled by default, but you can enforce them via command-line arguments to avoid any manual setup:
# Force-enable Brave Shields brave_options.add_argument("--enable-features=BraveShields") # Disable the ability to turn Shields off (optional, for consistency) brave_options.add_argument("--disable-features=BraveShieldsDisabled")
Alternatively, you can pre-configure Shields settings in Brave’s UI (like setting default image blocking) so every new driver session inherits those rules—no extra code needed.
Potential Pitfalls to Watch For
- Auto-updates: If Brave auto-updates its Chromium kernel, you’ll need to update ChromeDriver to match the new version to avoid compatibility errors.
- Brave-exclusive features: Avoid using Tor mode or private window-specific settings unless you explicitly need them—regular browsing windows work best with ChromeDriver.
- Path differences: Double-check the Brave binary path for your OS; it varies between Windows, Mac, and Linux.
Final Verdict
This setup will let you replace all your custom interceptor code with Brave’s battle-tested, built-in tools. It’s a clean, low-maintenance solution that should give you the speed boost you’re looking for.
内容的提问来源于stack exchange,提问作者sapbucket

