Hello. I have a simple Selenium code for Brave as follows:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
# Đường dẫn đến trình duyệt Brave
BRAVE_PATH = "C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"
# Tạo cấu hình cho Brave
options = Options()
options.binary_location = BRAVE_PATH
#options.add_argument("--incognito") # Chế độ ẩn danh
options.add_experimental_option(
"mobileEmulation", {"deviceName": "Pixel 7"}
)
# Khởi chạy trình duyệt Brave với Selenium
# Đường dẫn đến chromedriver
service = Service("F:\\VSCODE\\brave-seleniumbase\\chromedriver.exe")
driver = webdriver.Chrome(service=service, options=options)
# Mở một trang web để kiểm tra
driver.get("https://www.google.com")
# Đợi để xem kết quả (thời gian chờ có thể tùy chỉnh)
input("Nhấn Enter để thoát...")
driver.quit()
When I opened the two brave://version windows to compare, there was a clear difference. It seems that when using selenium, the block fingerprint function does not work and Active Variations are not available in selenium. Can anyone answer it for me?
The image on the left is selenium and the image on the right is without selenium
@zxczxcdev I can make a lot of assumptions, but overall will tag in @Mattches in case he might have some specific answer as someone from Brave, or at least able to ping a dev internally to get the answer.
In the meanwhile, I’m going to copy/paste a ChatGPT reply below. I’m not sure of the accuracy of the response but typically it’s been good on answers:
The behavior you’re observing is likely due to how browsers interact with automation tools like Selenium. When a browser is controlled by Selenium, it enters a specific mode that can sometimes disable or alter certain features. Here’s why this might be happening:
Automation Detection: Many browsers, including Brave, can detect when they’re being controlled by automation tools like Selenium. In this mode, certain features like fingerprinting protections might behave differently or get disabled. This is typically done to ensure compatibility with testing frameworks but can affect features designed for standard browsing.
Command Line Flags and Capabilities: Some features, such as Active Variations and fingerprinting protections, rely on runtime conditions that may not be set when launching Brave via Selenium. For example, the --remote-debugging-port or other flags added by Selenium might inadvertently bypass some protections or features.
Workaround: To ensure features like fingerprinting protection are enabled, you might need to explicitly set the necessary flags or capabilities. Try adding arguments in your options configuration to replicate standard browsing behavior. For example:
Note that this won’t guarantee full parity, as some differences are inherent to Selenium’s automation mode.
Limitations with Variations: Brave’s Active Variations might not initialize properly in automated sessions because these features often rely on background services that don’t fully activate in Selenium sessions.
Further Debugging: To dive deeper, you can compare the exact command line arguments being passed during a regular session (brave://version) and a Selenium session. Adjust your Selenium options to match these flags as closely as possible.