[🐛 Bug]: Edge Browser launching and signing with default user
What happened?
I am using a script where i want to launch the edge browser and signin automatically to use the browser. The code that i am using is throws an error called session is not created. `from selenium import webdriver import time
options = webdriver.EdgeOptions() options.add_argument("user-data-dir=C:\Users\Pasupuleti.Chandra\AppData\Local\Microsoft\Edge\User Data") options.add_argument("profile-directory=Default") driver = webdriver.Edge(options=options) driver.get('https://www.geeksforgeeks.org/python-programming-language/') time.sleep(1000)`
Below is the error snip:
How can we reproduce the issue?
from selenium import webdriver
import time
options = webdriver.EdgeOptions()
options.add_argument("user-data-dir=C:\\Users\\Pasupuleti.Chandra\\AppData\\Local\\Microsoft\\Edge\\User Data")
options.add_argument("profile-directory=Default")
driver = webdriver.Edge(options=options)
driver.get('https://www.geeksforgeeks.org/python-programming-language/')
time.sleep(1000)
Relevant log output
Opening in existing browser session.
ERROR:root:Error while creating Edge driver: Message: session not created: Microsoft Edge failed to start: exited normally.
(session not created: DevToolsActivePort file doesn't exist)
(The process started from msedge location C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe is no longer running, so msedgedriver is assuming that msedge has crashed.)
Stacktrace:
GetHandleVerifier [0x00007FF71B63E4F2+63026]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF71B5D0FC2+213746]
(No symbol) [0x00007FF71B3FE7A7]
(No symbol) [0x00007FF71B431101]
(No symbol) [0x00007FF71B42D147]
(No symbol) [0x00007FF71B46EE2C]
(No symbol) [0x00007FF71B464B43]
(No symbol) [0x00007FF71B43A33E]
(No symbol) [0x00007FF71B4394EC]
(No symbol) [0x00007FF71B439EF1]
Microsoft::Applications::Events::EventProperty::to_string [0x00007FF71B7E5714+1025332]
(No symbol) [0x00007FF71B4AF29C]
Microsoft::Applications::Events::EventProperty::~EventProperty [0x00007FF71B54BD3C+34028]
Microsoft::Applications::Events::EventProperty::~EventProperty [0x00007FF71B544525+3285]
Microsoft::Applications::Events::EventProperty::to_string [0x00007FF71B7E46D5+1021173]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF71B5D9A81+249265]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF71B5D5504+231476]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF71B5D563B+231787]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF71B5CB265+189845]
BaseThreadInitThunk [0x00007FFA979A257D+29]
RtlUserThreadStart [0x00007FFA989AAA48+40]
Traceback (most recent call last):
File "c:\Users\Pasupuleti.Chandra\conc.py", line 12, in <module>
driver = webdriver.Edge(service=service, options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Pasupuleti.Chandra\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\edge\webdriver.py", line 45, in __init__
super().__init__(
File "C:\Users\Pasupuleti.Chandra\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 61, in __init__
super().__init__(command_executor=executor, options=options)
File "C:\Users\Pasupuleti.Chandra\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 208, in __init__
self.start_session(capabilities)
File "C:\Users\Pasupuleti.Chandra\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 292, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Pasupuleti.Chandra\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 347, in execute
self.error_handler.check_response(response)
File "C:\Users\Pasupuleti.Chandra\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Microsoft Edge failed to start: exited normally.
(session not created: DevToolsActivePort file doesn't exist)
(The process started from msedge location C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe is no longer running, so msedgedriver is assuming that msedge has crashed.)
Stacktrace:
GetHandleVerifier [0x00007FF71B63E4F2+63026]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF71B5D0FC2+213746]
(No symbol) [0x00007FF71B3FE7A7]
(No symbol) [0x00007FF71B431101]
(No symbol) [0x00007FF71B42D147]
(No symbol) [0x00007FF71B46EE2C]
(No symbol) [0x00007FF71B464B43]
(No symbol) [0x00007FF71B43A33E]
(No symbol) [0x00007FF71B4394EC]
(No symbol) [0x00007FF71B439EF1]
Microsoft::Applications::Events::EventProperty::to_string [0x00007FF71B7E5714+1025332]
(No symbol) [0x00007FF71B4AF29C]
Microsoft::Applications::Events::EventProperty::~EventProperty [0x00007FF71B54BD3C+34028]
Microsoft::Applications::Events::EventProperty::~EventProperty [0x00007FF71B544525+3285]
Microsoft::Applications::Events::EventProperty::to_string [0x00007FF71B7E46D5+1021173]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF71B5D9A81+249265]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF71B5D5504+231476]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF71B5D563B+231787]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF71B5CB265+189845]
BaseThreadInitThunk [0x00007FFA979A257D+29]
RtlUserThreadStart [0x00007FFA989AAA48+40]
Operating System
windows 10
Selenium version
Python 3.11 selenium 4.11.2
What are the browser(s) and version(s) where you see this issue?
Edge Version 124.0.2478.97
What are the browser driver(s) and version(s) where you see this issue?
Edge driver automatically install
Are you using Selenium Grid?
No
@gitkdp2844, 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!
What happens when you use the latest version? (4.20 at the time).
If you still get errors, please share the execution logs with debug level.
It is same for latest version also,
Opening in existing browser session. Error : Message: session not created: Microsoft Edge failed to start: exited normally. (session not created: DevToolsActivePort file doesn't exist) (The process started from msedge location C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe is no longer running, so msedgedriver is assuming that msedge has crashed.)
@gitkdp2844 i think you should add -- before the argument name
options.add_argument("--user-data-dir=C:\\Users\\Pasupuleti.Chandra\\AppData\\Local\\Microsoft\\Edge\\User Data")
options.add_argument("--profile-directory=Default")
Tried in that way also same error session not created.
https://www.selenium.dev/documentation/webdriver/browsers/edge/#service
You should run the code with debug logging in MSEdgeDriver to see more details.
log.txt Attaching log with debug mode
`from selenium import webdriver import time import logging
try: log_path = "C:\Users\Pasupuleti.Chandra\Desktop\log.txt" service = webdriver.EdgeService(log_output=log_path) options = webdriver.EdgeOptions() options.add_argument("--user-data-dir=C:\Users\Pasupuleti.Chandra\AppData\Local\Microsoft\Edge\User Data") options.add_argument("--profile-directory=Default") driver = webdriver.Edge(service=service, options=options) driver.get('https://www.geeksforgeeks.org/python-programming-language/') with open(log_path, 'r') as fp: assert "Starting Microsoft Edge WebDriver" in fp.readline() time.sleep(1000) except Exception as e: print('Error : ',e)`
[1715747425.002][INFO]: Launching Microsoft Edge: "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 --profile-directory=Default --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\Pasupuleti.Chandra\AppData\Local\Microsoft\Edge\User Data" [1715747425.230][INFO]: [885187170544ddcc0a76daaa17f64ab3] RESPONSE InitSession ERROR session not created: Microsoft Edge failed to start: exited normally. (session not created: DevToolsActivePort file doesn't exist) (The process started from msedge location C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe is no longer running, so msedgedriver is assuming that msedge has crashed.)
Try launching Edge with the command shown in the logs and see if the error reproduces. There is probably something that needs tweaking in the parameters you are sending.
It is opening the browser but not signing in current user, I want to open browser with signin to existing user
I understand. In theory, the profile setting should work, but things have changed with MS Edge.
I will close this issue because it is not related to Selenium; instead, it is a question of how to open MS Edge with a profile signed in to a given service. You can use the links below to post questions.
💬 Please ask questions at:
- 📫 The Selenium user group
- 📮 StackOverflow
- 🗣 Our IRC/Slack/Matrix channels where the community can help you as well
This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.