Skip to content

[🐛 Bug]: Selenium SessionNotCreatedException: "User data directory is already in use" #15327

@ammarft-ai

Description

@ammarft-ai

What happened?

I am trying to launch a headless Chrome WebDriver using Selenium in Python. However, I keep encountering this error:

How can we reproduce the issue?

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

def createModel():
    service = Service(ChromeDriverManager().install())
    options = webdriver.ChromeOptions()
    
    # Specifying user data directory
    options.add_argument("--user-data-dir=/root/video-downloader/tmp/selenium-user-data")  
    options.add_argument("--headless=new")
    options.add_argument("--start-maximized")

    driver = webdriver.Chrome(service=service, options=options)
    return driver

driver = createModel()
driver.get("https://www.google.com")
print(driver.title)
driver.quit()

Relevant log output

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: probably user data directory is already in use, 
please specify a unique value for --user-data-dir argument, or don't use --user-data-dir

Operating System

Ubuntu

Selenium version

4.29.0

What are the browser(s) and version(s) where you see this issue?

Chrome

What are the browser driver(s) and version(s) where you see this issue?

Google Chrome 133.0.6943.126 ChromeDriver stable(auto)

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-defectSomething is not working as intendedI-questionApplied to questions. Issues should be closed and send the user to community resources.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions