[Python] how can i fix selenium edge driver error: session not created?

Discussão em 'Python' iniciado por Stack, Abril 25, 2025.

  1. Stack

    Stack Membro Participativo

    I am a newbie and trying to write a picture parser, starting to learn parsing have a code that gives an error, how can I fix it

    def setup_browser():
    options = EdgeOptions()
    options.add_argument('--start-maximized')
    options.add_argument('--no-sandbox')
    options.add_argument('--disable-dev-shm-usage')
    options.add_argument('--disable-blink-features=AutomationControlled')
    options.add_experimental_option('excludeSwitches', ['enable-automation'])
    options.add_experimental_option('useAutomationExtension', False)
    options.add_argument('--disable-gpu')
    options.add_argument('--disable-software-rasterizer')
    try:
    driver_manager = EdgeChromiumDriverManager()
    driver_path = driver_manager.install()
    service = EdgeService(driver_path)
    driver = webdriver.Edge(service=service, options=options)
    logging.info(f"Edge driver installed: {driver_path}")
    except Exception as e:
    logging.error(f"Error driver installed: {str(e)}")
    raise e
    driver.execute_script(
    "Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"
    )
    return driver


    And i get error:

    Message: session not created: probably user data directory is already in us
    e, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir

    Continue reading...

Compartilhe esta Página