Prerequisites:
Your chromedriver
version should match your Brave Browser
web driver version.
To make sure it does:
- Check
ChromeDriver
version with brew info chromedriver
. Along the lines of the output it should read chromedriver: 89.0.4389.23
(latest version as of writing this post)
- Open
Brave Browser
, in menu bar click Brave
-> About Brave
. Along the lines it should read Version 1.22.71 Chromium: 89.0.4389.114 (Official Build) (x86_64)
(again, latest as of writing this post)
- These two should match, however, i am not entirely sure to which degree, since, as you can see here, last entries (
.23
and .114
) don't match, yet this works perfectly fine on my machine (macOS Big Sur 11.2.3
) I don't think macOS version should really matter, but i still mentioned it for the sake of completeness.
Finally run the following code (replace paths with ones on your machine if they are different):
from selenium import webdriver
driverPath = '/usr/local/Caskroom/chromedriver/89.0.4389.23/chromedriver'
binaryPath = '/Applications/Brave Browser.app/Contents/MacOS/Brave Browser'
options = webdriver.ChromeOptions()
options.binary_location = binaryPath
browser = webdriver.Chrome(executable_path=driverPath, chrome_options=options)
browser.get("https://www.google.es")
If you have never used chromedriver
before, after runnning the code you should see a macOS prompt saying that chromedriver
is from unknown developer or was downloaded from the internet, smth like that. Close that prompt (It's important that you do this before moving on). Then go to System Preferences
-> Security & Privacy
-> press the lock icon and unlock it and then approve chromedriver
to run on your machine. Run the above code again, a new macOS prompt will appear saying smth about unknown developer again, this time you can just click Open. Brave Browser window should pop up at this point. At least it did on my machine.
P.S. I apologise for possibly going into too much detail, but sometimes i get really frustrated with answers which skip parts which are considered to be obvious