Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With user-data-dir set to "C\Users\{user}\AppData\Local\Microsoft\Edge\User Data". SessionNotCreatedException occurs when launch Selenium. #125

Open
YoheiSuda2 opened this issue Nov 20, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@YoheiSuda2
Copy link

The error occurs when performing the operation as subject. (I believe the problem is specific to the Edge side, as it was not reproduced with the Chrome Driver)

My environment is as follows.
OS: Windows11
Selenium: 4.10.0
Edge: 119.0.2151.72
Edge Driver: 119.0.2151.32

Below is the log.

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. 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.) Host info: host: 'DESKTOP-TBM0T59', ip: '192.168.0.39'Build info: version: '4.10.0', revision: 'c14d967899'System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.14.1'Driver info: org.openqa.selenium.edge.EdgeDriverCommand: [null, newSession {capabilities=[Capabilities {browserName: MicrosoftEdge, ms:edgeOptions: {args: [--start-maximized, --user-data-dir=C:\Users\su...], extensions: [], prefs: {user_experience_metrics: {personalization_data_consent_enabled: true}}}, ms:ms:loggingPrefs: org.openqa.selenium.logging...}]}]
org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:140)
org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:96)
org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:68)
org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:196)
org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:171)
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:531)
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:227)
org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:154)
org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:107)
org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:59)
org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:55)
org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:47)

Thanks.

@YoheiSuda2 YoheiSuda2 added the bug Something isn't working label Nov 20, 2023
@bwalderman
Copy link
Member

Hi @YoheiSuda2. It looks like Edge is crashing during startup. I will need some more info to investigate further. Are you able to share a short code sample / minimal website that reproduces the issue?

@YoheiSuda2
Copy link
Author

@bwalderman
Thank you for replying.

I'm too busy to provide a sample, so I'll give you the details of the current situation.
Simply passing "C\Users{user}\AppData\Local\Microsoft\Edge\User Data "to --user-data-dir causes a crash, which is reproduced in my environment.
I can work around it by passing "C\Users{user}\AppData\Local\Microsoft\Edge\User Data\Default", but I am unable to specify directly under User Data as before.
Selenium is used in Java 11.

If necessary, we will create a sample and provide it to you after the new year.

@crimsonvspurple
Copy link

This is still a valid issue.

Everything works until user-data-dir option is passed. Then Edge starts but session can't be created.

options.addArguments("user-data-dir=" + userDataDir);

Without this line, it will start edge, load the temp profile, load the site and quit.

With this line, it will start edge, it will load correct profile (fav, session, top right user icon etc) but edgedriver can't connect. It will also not open the site.

Error:

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. 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.) 
Host info: host: 'WIN11', ip: '169.254.123.3'
Build info: version: '4.22.0', revision: 'c5f3146703*'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '21.0.2'
Driver info: org.openqa.selenium.edge.EdgeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: MicrosoftEdge, ms:edgeOptions: {args: [user-data-dir=C:\Users\...], extensions: []}}]}]
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:114)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:61)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:162)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:518)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:232)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:161)
	at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:114)
	at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:60)
	at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:56)
	at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:48)

Here's your repro:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;

public class Main {

    public static void main(String[] args) {
        final WebDriver driver;

        final String userHome = System.getProperty("user.home");
        final String userDataDir = userHome + "\\AppData\\Local\\Microsoft\\Edge\\User Data";
        //noinspection SpellCheckingInspection
        final String edgeDriverPath = userHome + "\\Downloads\\edgedriver_win64\\msedgedriver.exe";


        // Set the path to the Edge WebDriver executable
        System.setProperty("webdriver.edge.driver", edgeDriverPath);

        // Set up Edge options to use the existing user data directory
        EdgeOptions options = new EdgeOptions();
        // options.addArguments("user-data-dir=" + userDataDir); // UNCOMMENT THIS AND IT WILL NOT WORK
        // Initialize the Edge WebDriver with the specified options
        driver = new EdgeDriver(options);

        driver.get("https://example.com");

        try {
            Thread.sleep(5000); // Wait for 5 seconds
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        driver.quit();
    }
}

POM:

    <dependencies>
        <!-- Selenium dependencies -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.22.0</version>
        </dependency>

        <!-- Additional dependencies for Edge WebDriver -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-edge-driver</artifactId>
            <version>4.22.0</version>
        </dependency>
    </dependencies>

@mikeangflo
Copy link

@YoheiSuda2 , @crimsonvspurple - Did either of you ever find a solution to this? I am facing the same problem with user-data-dir argument in options.

@michasanyi
Copy link

michasanyi commented Aug 28, 2024 via email

@crimsonvspurple
Copy link

@YoheiSuda2 , @crimsonvspurple - Did either of you ever find a solution to this? I am facing the same problem with user-data-dir argument in options.

I moved to Chrome. Seems like MS don't care about this.

@Betterchildren
Copy link

@YoheiSuda2 , @crimsonvspurple - Did either of you ever find a solution to this? I am facing the same problem with user-data-dir argument in options.

I moved to Chrome. Seems like MS don't care about this.

but the Chrome has the same problem :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants