Opening more than one brave profile using selenium python

291 views
Skip to first unread message

Mor1

unread,
Mar 16, 2024, 3:37:32 AM3/16/24
to Selenium Users
I'm trying to open multiple brave profiles at the same time using the following code:

from selenium import webdriver 
import time 
from selenium.webdriver.chrome.service import Service
drivers = [] 
for i in range(15):
     option = webdriver.ChromeOptions()
     option.binary_location = "path to brave.exe" 
     option.add_argument(f"--profile-directory=Profile {i}")
     option.add_argument(f"--user-data-dir=AppData\\Local\\BraveSoftware\\Brave-Browser\\User Data")
     s = Service(chromedriver)
     driver = webdriver.Chrome(service=s, options=option) driver.get("https://google.com"       drivers.append(driver) time.sleep(6)


but upon executing, it opens 2 brave instances and then terminates. 
it also gives me the following error: 




DevTools listening on ws://127.0.0.1:53952/devtools/browser/cf93ee3c-b9b4-4f89-9dbc-dfdc18107406 Opening in existing browser session. Traceback (most recent call last): File "brave.py", line 24, in <module> driver = webdriver.Chrome(service=s, options=option) File "Python\Python310\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__ super().__init__( File "Python\Python310\site-packages\selenium\webdriver\chromium\webdriver.py", line 61, in __init__ super().__init__(command_executor=executor, options=options) File "Python\Python310\site-packages\selenium\webdriver\remote\webdriver.py", line 208, in __init__ self.start_session(capabilities) File "Python\Python310\site-packages\selenium\webdriver\remote\webdriver.py", line 292, in start_session response = self.execute(Command.NEW_SESSION, caps)["value"] File "Python\Python310\site-packages\selenium\webdriver\remote\webdriver.py", line 347, in execute self.error_handler.check_response(response) File "Python\Python310\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally. (session not created: DevToolsActivePort file doesn't exist) (The process started from chrome location AppData\Local\BraveSoftware\Brave-Browser\Application\brave.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Sir Jo

unread,
Mar 16, 2024, 9:38:53 AM3/16/24
to Selenium Users
you can try to use different port on each instances using
option.add_argument(f"--remote-debugging-port=xxxx")
xxxx maybe, for example, 9222+i

Mor1

unread,
Mar 16, 2024, 9:55:05 AM3/16/24
to Selenium Users
It still gives the same error. 

Kfir Ben Hamo

unread,
Mar 16, 2024, 1:17:00 PM3/16/24
to seleniu...@googlegroups.com
Pls check you are setting new devtools port for each seesion and validate port is free before assinging it

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/22df1d67-fa70-47ba-83bc-965687eb4b68n%40googlegroups.com.

Mor1

unread,
Mar 20, 2024, 4:51:07 PM3/20/24
to Selenium Users

I checked for the availability of the ports before assigning every profile a port and it still gives the same error. 

Kfir Ben Hamo

unread,
Mar 20, 2024, 5:14:59 PM3/20/24
to seleniu...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages