How to load the default brave profile with selenium?

I’m using brave browser on the operating system Pop!_OS Linux. I’ve seen multiple answer on the web suggesting to do it through adding an argument being the --user-data-dir and assigning the path of the default browser folder to it. I’ve done this using line of code:

    options.add_argument(r"--user-data-dir=/home/sxvxge/.config/BraveSoftware/Brave-Browser/Default")

options was defined as and was used as the following:

    options = webdriver.ChromeOptions()
    options.binary_location = '/opt/brave.com/brave/brave'
    options.add_argument(r"--user-data-dir=/home/sxvxge/.config/BraveSoftware/Brave-Browser/Default")

options was also used when defining the driver:

service = Service(self.chromedriver) # self.chromedriver is the path to the chromedriver
driver : WebDriver = webdriver.Chrome(service=service, options=options)

However, when launching a browser instance with selenium, by using driver.get(), the instance wouldn’t have the profile data loaded at all. I couldn’t find a solution to my problem no matter what I tried. What could I do to fix this issue?

Note: All paths used in the code are valid.

Unfortunately I don’t have an answer for you, but I’m curious what the rest of your code looks like, especially if you have a Docekrfile! I’ve considered running Brave with something like Selenium (e.g., to scrape/test sites that require JS), but I haven’t found any easy “hello world” examples to get started.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.