How to use Brave web browser with python, selenium and chromedriver? How to use Brave web browser with python, selenium and chromedriver? selenium selenium

How to use Brave web browser with python, selenium and chromedriver?


I finally managed to make it work:

Try this python script (python3.7)

from selenium import webdriverdriver_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 Chromebrowser = webdriver.Chrome(executable_path=driver_path, chrome_options=option)browser.get("https://www.google.es")

cheers.


The executable_path key is used to pass the absolute path of the WebDriver binary i.e. the chromedriver executable.

To initiate a Brave browser session additionally you have to pass the absolute location of the brave-browser binary through the binary_location argument of an instance of ChromeOptions.

So the effective code block will be:

from selenium import webdriverchromedriver_path = '/usr/bin/chromedriver'brave_path = '/usr/bin/brave-browser'option = webdriver.ChromeOptions()option.binary_location = brave_pathbrowser = webdriver.Chrome(executable_path=driver_path, options=option)browser.get("https://www.google.es")

References

You can find a couple of relevant detailed discussions in:


This also works in windows 10 with Brave browser. I downloaded Chromedriver and put it in the folder with Brave.exe.

from selenium import webdriverdriver_path = "C:\\Users\\5150s\\AppData\\Local\\Programs\\Python\\Python38\\chromedriver.exe"brave_path = "C:\\Program Files (x86)\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"option = webdriver.ChromeOptions()option.binary_location = brave_pathbrowser = webdriver.Chrome(executable_path=driver_path, options=option)browser.get("https://www.google.es")