1

I'm currently using SeleniumBase with UC mode to launch a web page. After starting a browser instance in one script, I would like to reuse that instance in another script within the same project. However, when I attempt to do this, a new browser window opens instead of reusing the existing one.

Is there a way to continue using the same driver instance across different scripts without launching a new browser? Any guidance or best practices for achieving this would be greatly appreciated.

Here's a snippet of my code:

from seleniumbase import Driver
from time import sleep

my_user_dir = "C:/ProgramData/Midbots/User Data/Chrome Data"
url = "https://www.midddleman.co/"


def launch_driver():
    # ############ LAUNCH BROWSER ############
    driver = Driver(uc=True, headless=None, user_data_dir=my_user_dir, disable_gpu=True)
    driver.uc_open_with_reconnect(url, 5)
    driver.uc_gui_click_captcha()
    sleep(5)

    return driver

launch_driver()

I want to keep working with the same webpage in another script using the existing driver instance without opening a new browser. Any advice would be greatly appreciated!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.