System:
OS: Ubuntu 20.04.2 LTS
Python: 3.8.5
selenium: 3.141.0
ChromeDriver: 90.0.4430.24
Brave: Version 1.24.86 Chromium: 90.0.4430.212 (Official Build) (64-bit)
I am trying to get Selenium to work with Brave. I am using the script from here.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = '/snap/bin/brave'
driver_path = '/usr/local/bin/chromedriver'
drvr = webdriver.Chrome(options=options, executable_path=driver_path)
drvr.get('https://stackoverflow.com')
I keep getting this error
selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist
And I have tried all the answers in stackflow I tried all different combinations of these arguments but nothing worked:(
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("--disable-gpu")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--no-sandbox")
options.add_argument('--remote-debugging-port=9222')
options.add_argument('--headless')
Can anyone help me out?
I was able to get it working by changing the remote-debugging-port to a different port.
Here is my code that worked.
I did see a tip here about using an opera driver, which i found here, but it did not solve my error.
The issue was that after running the script once the process was not killed and was still running in the background so the port was taken and failed on all subsequent runs until I changed the port (or killed the process). The question is why is close() not working in brave when headless, it is working for chrome!