Skip to content

[🐛 Bug]: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 (SessionNotCreated) #15340

Closed
@maurod83

Description

@maurod83

What happened?

I have an application using Selenium to automate Edge browser that throws this error message: 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 (SessionNotCreated)
This error happens using a new profile directory too.

When I run this app manually for the first time it throws this exception:

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 (SessionNotCreated)

StackTrace:
at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options)
at AppWeb.frmAppWeb.EjecutarConexion()

And creates automatically an entry in Windows Registry key "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store".
When I run the application again it works as expected. If I remove this entry, error shows up again.

On the first try (with error) msedge.exe commandline is:

"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --allow-pre-commit-input --disable-background-networking --disable-backgrounding-occluded-windows --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-logging --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\MAUROD~1\AppData\Local\Temp\scoped_dir8168_1802574373" --edge-skip-compat-layer-relaunch data:,

On the second try (without error) msedge.exe commandline is:

"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --allow-pre-commit-input --disable-background-networking --disable-backgrounding-occluded-windows --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-logging --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\MAUROD~1\AppData\Local\Temp\scoped_dir18024_701312417" data:,

This error happens when I run my application for the first time and it happens every time I run it using "Run As Administrator"
If I run it from another process that was called from a browser extension using Native Messaging it happens every time too.

If I call msedgedriver directly using a HTTP Post to start a new session, it executes without any error.

How can we reproduce the issue?

Code snippets (C#):
var service = EdgeDriverService.CreateDefaultService();

var options = new EdgeOptions();
var driver = new EdgeDriver((EdgeDriverService)service, (EdgeOptions)options);

Relevant log output

2025-02-24 23:18:18.999 TRACE SeleniumManager: DEBUG msedgedriver not found in PATH
2025-02-24 23:18:19.001 TRACE SeleniumManager: DEBUG MicrosoftEdge detected at C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
2025-02-24 23:18:19.001 TRACE SeleniumManager: DEBUG Running command: wmic datafile where name='C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe' get Version /value
2025-02-24 23:18:19.001 TRACE SeleniumManager: DEBUG Output: "\r\r\n\r\r\nVersion=133.0.3065.82\r\r\n\r\r\n\r\r\n\r"
2025-02-24 23:18:19.001 TRACE SeleniumManager: DEBUG Detected browser: MicrosoftEdge 133.0.3065.82
2025-02-24 23:18:19.001 TRACE SeleniumManager: DEBUG Required driver: msedgedriver 133.0.3065.82
2025-02-24 23:18:19.002 TRACE SeleniumManager: DEBUG msedgedriver 133.0.3065.82 already in the cache
2025-02-24 23:18:19.002 TRACE SeleniumManager: INFO Driver path: C:\Users\Mauro Dimare\.cache\selenium\msedgedriver\win64\133.0.3065.82\msedgedriver.exe
2025-02-24 23:18:19.002 TRACE SeleniumManager: INFO Browser path: C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
2025-02-24 23:18:19.002 TRACE SeleniumManager: Driver path: C:\Users\Mauro Dimare\.cache\selenium\msedgedriver\win64\133.0.3065.82\msedgedriver.exe
2025-02-24 23:18:19.002 TRACE SeleniumManager: Browser path: C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
2025-02-24 23:18:19.592 DEBUG HttpCommandExecutor: Executing command: []: newSession
2025-02-24 23:18:19.634 TRACE HttpCommandExecutor: >> POST RequestUri: http://localhost:45960/session, Content: System.Net.Http.ByteArrayContent, Headers: 2
{"capabilities":{"firstMatch":[{"browserName":"MicrosoftEdge","ms:edgeOptions":{"binary":"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"}}]}}
2025-02-24 23:18:19.715 TRACE HttpCommandExecutor: << StatusCode: 500, ReasonPhrase: Internal Server Error, Content: System.Net.Http.StreamContent, Headers: 1
{"value":{"error":"session not created","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","stacktrace":"\tGetHandleVerifier [0x00007FF68182E735+13397]\n\tMicrosoft::Applications::Events::EventProperty::empty [0x00007FF681ABB1B4+2060276]\n\tMicrosoft::Applications::Events::EventProperty::empty [0x00007FF681A12338+1368440]\n\t(No symbol) [0x00007FF6815F0382]\n\t(No symbol) [0x00007FF6815EA827]\n\t(No symbol) [0x00007FF68162FD84]\n\t(No symbol) [0x00007FF681623FC3]\n\t(No symbol) [0x00007FF6815F8B96]\n\t(No symbol) [0x00007FF6815F7E50]\n\t(No symbol) [0x00007FF6815F89C3]\n\t(No symbol) [0x00007FF681680214]\n\t(No symbol) [0x00007FF6817106CF]\n\t(No symbol) [0x00007FF681683A53]\n\tMicrosoft::Applications::Events::EventProperty::to_string [0x00007FF681B745BD+279981]\n\tsimdutf::get_active_implementation [0x00007FF6817B78C1+409457]\n\tsimdutf::get_active_implementation [0x00007FF6817B2BA4+389716]\n\tsimdutf::get_active_implementation [0x00007FF6817B2CE9+390041]\n\tsimdutf::get_active_implementation [0x00007FF6817A62E6+338326]\n\tBaseThreadInitThunk [0x00007FFE4DF37374+20]\n\tRtlUserThreadStart [0x00007FFE4FDDCC91+33]\n"}}
2025-02-24 23:18:19.724 DEBUG HttpCommandExecutor: Response: ( SessionNotCreated: System.Collections.Generic.Dictionary`2[System.String,System.Object])

Operating System

Windows 10 x64 Version 22H2 (build 19045.5487)

Selenium version

4.29.0

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

Edge 133.0.3065.82

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

Edgedriver 133.0.3065.82

Are you using Selenium Grid?

No response

Activity

added
I-defectSomething is not working as intended
A-needs-triagingA Selenium member will evaluate this soon!
on Feb 26, 2025
github-actions

github-actions commented on Feb 26, 2025

@github-actions

@maurod83, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

cgoldberg

cgoldberg commented on Feb 26, 2025

@cgoldberg
Contributor

@maurod83
Please add a relevant title to this.

changed the title [-][🐛 Bug]:[/-] [+][🐛 Bug]: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 (SessionNotCreated)[/+] on Feb 26, 2025
janC4380

janC4380 commented on Feb 26, 2025

@janC4380

Probably related to the same issue, I am running tests using Selenium Webdriver using EdgeChromiumManager, but the msedgedriver version 133.0.3065.82 fails to create a session on the second time. Works when I use 132.0.2957.171

kkingdara-at-loginvsi

kkingdara-at-loginvsi commented on Feb 28, 2025

@kkingdara-at-loginvsi

adding the argument "--edge-skip-compat-layer-relaunch" to options seems to work for me.

otherwise, the path to the program (or the parent if there's one) that calls the webdriver needs to be in "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store" but this will only happen after the program has been opened at least once.

seems like a bug in Edge 133 but at least there's a workaround.

cheers

thos-grol

thos-grol commented on Mar 6, 2025

@thos-grol

adding the argument "--edge-skip-compat-layer-relaunch" to options seems to work for me.

otherwise, the path to the program (or the parent if there's one) that calls the webdriver needs to be in "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store" but this will only happen after the program has been opened at least once.

seems like a bug in Edge 133 but at least there's a workaround.

cheers

THANK GOD, you fixed it for me. I had a multiprocess scraper I spent a few hours debugging. Honestly dumb webdriver changes breaking things.

Was leveraging the edge browser's autotranslation function using jquery to go from top to bottom of page and then scraping thousands of pages.

puatrap

puatrap commented on Mar 11, 2025

@puatrap

adding the argument "--edge-skip-compat-layer-relaunch" to options seems to work for me.

otherwise, the path to the program (or the parent if there's one) that calls the webdriver needs to be in "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store" but this will only happen after the program has been opened at least once.

seems like a bug in Edge 133 but at least there's a workaround.

cheers

You are my hero

iDonal

iDonal commented on Mar 20, 2025

@iDonal

adding the argument "--edge-skip-compat-layer-relaunch" to options seems to work for me.

otherwise, the path to the program (or the parent if there's one) that calls the webdriver needs to be in "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store" but this will only happen after the program has been opened at least once.

seems like a bug in Edge 133 but at least there's a workaround.

cheers

You are my hero, fix the random f**king bug

Galotar

Galotar commented on Mar 27, 2025

@Galotar

adding the argument "--edge-skip-compat-layer-relaunch" to options seems to work for me.

otherwise, the path to the program (or the parent if there's one) that calls the webdriver needs to be in "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store" but this will only happen after the program has been opened at least once.

seems like a bug in Edge 133 but at least there's a workaround.

cheers

Same for me, adding this finally fixed my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!I-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @titusfortner@cgoldberg@iDonal@Galotar@thos-grol

      Issue actions

        [🐛 Bug]: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 (SessionNotCreated) · Issue #15340 · SeleniumHQ/selenium