问题
Using:
- ChromeDriver 83.0.4103.39
- Brave Version 1.10.97 Chromium: 83.0.4103.116 (Official Build) (64-bit)
- Python 3.7
- Windows 10
Code trials:
from selenium import webdriver
driver_path = "C:/Users/username/PycharmProjects/chromedriver.exe"
brave_path = "C:/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"
option = webdriver.ChromeOptions()
option.binary_location = brave_path
# option.add_argument("--incognito") OPTIONAL
# option.add_argument("--headless") OPTIONAL
# Create new Instance of Chrome
browser = webdriver.Chrome(executable_path=driver_path, chrome_options=option)
browser.get("https://www.google.com")
I'm getting this error
DevTools listening on ws://127.0.0.1:54230/devtools/browser/406d1094-cd8c-48d5-930d-b7308f621429
[8696:16300:0628/131830.277:ERROR:rewards_service_impl.cc(242)] Failed to read file: C:\Users\Admin\AppData\Local\Temp\scoped_dir13924_173218860\Default\rewards_service\confirmations.json
[9492:5280:0628/131830.304:ERROR:confirmations_impl.cc(774)] Failed to load confirmations state, resetting to default values
[8696:2268:0628/131830.405:ERROR:rewards_service_impl.cc(191)] Failed to read file: C:\Users\Admin\AppData\Local\Temp\scoped_dir13924_173218860\Default\ledger_state
[9492:5280:0628/131830.410:ERROR:ledger_impl.cc(122)] Failed to initialize wallet
回答1:
To open a brave Browsing Context using Selenium driven WebDriver you can use the following solution:
Code Block:
from selenium import webdriver option = webdriver.ChromeOptions() option.binary_location = r'C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe' driver = webdriver.Chrome(executable_path=r'C:\WebDrivers\chromedriver.exe', options=option) driver.get("https://www.google.com")
Browser Snapshot:
来源:https://stackoverflow.com/questions/62626853/how-to-initiate-brave-browser-using-selenium-and-python-on-windows