-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Description
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