MSEdge failed to start: crashed (chrome not reachable)
Asked Answered
S

1

6

I am a beginner to Selenium python. I have tried to invoke the Edge browser with an existing profile(Default) with the following code. But it is throwing the following exception as soon as the execution starts. Can someone please help me with this? Am I missing something?

edge_options = webdriver.EdgeOptions()
edge_options.add_argument("user-data-dir = C:/Users/XYZ/AppData/Local/Microsoft/Edge/User Data/Default")
edge_browser = webdriver.Edge(executable_path = "C:/Users/XYZ/ABC/msedgedriver.exe",options = edge_options )
edge_browser.maximize_window()

WebDriverException: unknown error: MSEdge 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.)

Note: Edge browser is getting invoked and works properly when I run the code without the following line

edge_options.add_argument("user-data-dir = C:/Users/XYZ/AppData/Local/Microsoft/Edge/User Data/Default")
Stifle answered 23/2, 2022 at 13:46 Comment(2)
Edge browser is getting invoked and works properly when I run the code without the following line: Are you sure about that?Labionasal
Yes, I commented on the add_argument line and executed the code, It is invoking the edge browser but when I uncommented it is showing the mentioned exception. I will have to use the default profile due to some reason.Stifle
M
7

I came across the issue before, that's because there're running Edge processes in the background. The solution is you can back up your User Data folder in the same path and use that folder in selenium:

  1. Back up your User Data folder in the same path. Here for example, I back up the User Data folder as User Data1:

    enter image description here

  2. Use User Data1 in your code to specify using Default profile when run Edge with Selenium:

    from selenium import webdriver
    from selenium.webdriver.edge.service import Service
    
    edge_options = webdriver.EdgeOptions()
    #Here you set the path of the back up profile ending with User Data1 not the profile folder 
    edge_options.add_argument("user-data-dir=C:\\Users\\XYZ\\AppData\\Local\\Microsoft\\Edge\\User Data1")  
    ser = Service("C:\\Users\\XYZ\\ABC\\msedgedriver.exe")    
    
    edge_browser = webdriver.Edge(options = edge_options, service=ser)
    edge_browser.maximize_window()
    
Mundt answered 24/2, 2022 at 7:15 Comment(9)
Thanks for the response! I have tried the way you mentioned, unfortunately, it did not work as well and got the same error WebDriverException: unknown error: MSEdge failed to start: crashed. (chrome not reachable)Stifle
Does the Edge browser in path C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe work well if you run it manually? Which version of Edge and Edge WebDriver are you using? Which version of Selenium are you using?Mundt
yes, when I launch edge browser it is working manually. I am using Selenium 4.1.0 , edge browser Version 98.0.1108.62 (Official build) (64-bit) and downloaded the corresponding web driver with the following link msedgedriver.azureedge.net/98.0.1108.62/edgedriver_win64.zipStifle
Do you use the exactly the same code as mine? It's strange it still doesn't work. You can try to end all the Edge processes in task manager and run the code with administrator privilege to test again. Besides, you can check Developer Tools Availability policy to see if it is set to 0 or 1.Mundt
Thank you! I killed edge processes and it worked!Stifle
I think the issue was related to path as I was using like this edge_options.add_argument("user-data-dir=C:/Users/XYZ/AppData/Local/Microsoft/Edge/User Data1")' Later had changed to edge_options.add_argument("user-data-dir=C:\\Users\\XYZ\\AppData\\Local\\Microsoft\\Edge\\User Data1") which is working fineStifle
what is the reasoning for ccopying and pasting as "User Data1" ?Culbreth
Still relevant ╰(°▽°)╯Joliejoliet
I got the same error, maybe it is that you can not use two process with edge browser.Libertarian

© 2022 - 2024 — McMap. All rights reserved.