-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Run seleniumbase with opened chrome browser and keep browser open between runs #3626
-
I would like to run automation task multiple times (with same code) to an already opend chrome browser. The first time the script can ran successfully but from second time I got below error
Message: unknown error: unable to discover open window in chrome (Session info: chrome=132.0.6834.84) Stacktrace: GetHandleVerifier [0x00007FF6D5E84C25+3179557] (No symbol) [0x00007FF6D5AE88A0] (No symbol) [0x00007FF6D59791CA] (No symbol) [0x00007FF6D59506B0] (No symbol) [0x00007FF6D5A05FF4] (No symbol) [0x00007FF6D5A05460] (No symbol) [0x00007FF6D59F7A03] (No symbol) [0x00007FF6D59C06D0] (No symbol) [0x00007FF6D59C1983] GetHandleVerifier [0x00007FF6D5EE67CD+3579853] GetHandleVerifier [0x00007FF6D5EFD1D2+3672530] GetHandleVerifier [0x00007FF6D5EF2153+3627347] GetHandleVerifier [0x00007FF6D5C5092A+868650] (No symbol) [0x00007FF6D5AF2FFF] (No symbol) [0x00007FF6D5AEF4A4] (No symbol) [0x00007FF6D5AEF646] (No symbol) [0x00007FF6D5ADEAA9] BaseThreadInitThunk [0x00007FFD144DE8D7+23] RtlUserThreadStart [0x00007FFD158FBF6C+44]
My scripts as below
chromium_arg = f"remote-debugging-port={remote_debugging_port},no-sandbox" with SB(uc=True, remote_debug=False, devtools=False, chromium_arg=chromium_arg) as sb: sb.driver.execute_script("window.open('', '_self');") # ✅ Prevent opening a new tab sb.open(url) sb.wait(15) """Check for 'Node is connected' text or 'Login' button""" if sb.wait_for_element_visible("//p[contains(text(), 'Node is connected')]", timeout=5) : print("✅ Success! Node is connected.") else: if sb.is_element_clickable("//button[contains(text(), 'Login')]"): sb.click("//button[contains(text(), 'Login')]") # Wait for the new tab to open sb.wait_for_new_window(timeout=5) print(f"✅ Current Tab Title: {sb.get_title()}") # Switch to the new tab sb.switch_to_window(sb.get_new_driver_window()) print(f"✅ Current Tab Title: {sb.get_title()}") sb.driver.quit()
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 3 replies
-
Then don’t quit the browser at the end of your script.
Beta Was this translation helpful? Give feedback.
All reactions
-
@mdmintz I didn’t close the browser, but I’m still encountering that error.
For more context, I’m using an antidetect browser and running parallel automation on multiple profiles with "async with semaphore." Not sure if that’s causing the issue.
Beta Was this translation helpful? Give feedback.
All reactions
-
As I understand, the expected workflow should be:
1. My antidetect browser (Chrome-based) is already open with --remote-debugging-port=xxx.
2. SB spawns another Chrome instance and sets up the driver.
3. SB uses the driver to connect to my existing browser instance via the remote debugging port from step 1.
However, what I observed is that the Chrome instance spawned by SB opens and then quits immediately, and I’m not sure why.
Beta Was this translation helpful? Give feedback.
All reactions
-
The code for taking control of existing Chrome browsers via the remote-debugging-port
is here:
Beta Was this translation helpful? Give feedback.