MicrosoftEdge / EdgeWebDriver

Feedback and discussions about WebDriver for Microsoft Edge
MIT License
55 stars 7 forks source link

session not created: Microsoft Edge failed to start: crashed #160

Open shanuwed opened 1 month ago

shanuwed commented 1 month ago

We have a Selenium automation that works fine when used with ChromeDriver in Azure VMSS. However, when I try with EdgeDriver it crashes:

System.InvalidOperationException: session not created: Microsoft Edge failed to start: crashed.
  (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.) (SessionNotCreated)
   at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
   at OpenQA.Selenium.WebDriver.<ExecuteAsync>d__63.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.WebDriver.StartSession(ICapabilities capabilities)
   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)

Depending on which Options I use, the error message can be slightly different (like --remote-debugging-port=):

System.InvalidOperationException: session not created: Microsoft Edge failed to start: crashed.
  (chrome not reachable)
  (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.) (SessionNotCreated)

This is the code that sets up the Options:

        private DriverOptions GetDriverOptions(Type driverType)
        {
            DriverOptions options = null;
            if (driverType == typeof(ChromeDriver)) 
            {
                options = new ChromeOptions();
                                (options as ChromeOptions).AddArgument("no-sandbox");
                                (options as ChromeOptions).AddArgument("--headless");
                                (options as ChromeOptions).AddArgument("--window-size=1920,1080");
                               (options as ChromeOptions).AddArgument("--start-maximized");
                        }
            else if (driverType == typeof(EdgeDriver))
            {
                options = new EdgeOptions();
            }
                        //... other driverTypes ...
            return options;
        }

I use Edge browser 127.0.2651.74 and the same version of Edge driver, Selenium.WebDriver 4.23.0 on Windows 2016 server. The error seems to happen in prod machine only. I have not been able to repro in other environment (not in windows 11 or non production Windows server.) I've tried these options combinations: 1) (options as EdgeOptions).AddArgument("--remote-debugging-port=4321"); 2) (options as EdgeOptions).AddArgument("--no-sandbox"); and (options as EdgeOptions).AddArgument("--headless"); 3) (options as EdgeOptions).AddArgument("no-sandbox"); and (options as EdgeOptions).AddArgument("disable-dev-shm-usage"); None of them worked. ChromeDriver with the options shown in the above code always works. Can you help?

midland55 commented 1 month ago

Same issue a @shanuwed with Remote WebDriver session vs Edge (v127.0.2651.86)

dmytro-makieiev commented 2 weeks ago

Got similar error to @shanuwed but I am running edge in the container on the linux: {"traceId": "54fee8d542dc2bbd09d9dc70a0761198","eventTime": 1724889889144116602,"eventName": "exception","attributes": {"driver.url": "http:\u002f\u002flocalhost:22447","exception.message": "Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: session not created\nfrom chrome not reachable \nHost info: host: 'e551bbeeb7d4', ip: '172.18.0.3'\nBuild info: version: '4.23.1', revision: '656257d8e9'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.153.1-microsoft-standard-WSL2', java.version: '17.0.12'\nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created\nfrom chrome not reachable \nHost info: host: 'e551bbeeb7d4', ip: '172.18.0.3