Reputation: 31
i'm using this code to open edge with the defaut profile settings:
from msedge.selenium_tools import Edge, EdgeOptions
edge_options = EdgeOptions()
edge_options.use_chromium = True
edge_options.add_argument("user-data-dir=C:\\Users\\PopA2\\AppData\\Local\\Microsoft\\Edge\\User Data\\Default")
edge_options.add_argument("profile-directory=Profile 1")
edge_options.binary_location = r"C:\\Users\\PopA2\\Downloads\\edgedriver_win64 (1)\\msedgedriver.exe"
driver = Edge(options = edge_options, executable_path = "C:\\Users\\PopA2\\Downloads\\edgedriver_win64 (1)\\msedgedriver.exe")
driver.get('https://google.com')
driver.quit()
but i am getting this error:
PS C:\Users\PopA2> & "C:/Program Files/Python37/python.exe" "c:/Users/PopA2/OneDrive/Desktop/test de pe net.py" Traceback (most recent call last): File "c:/Users/PopA2/OneDrive Group/Desktop/test de pe net.py", line 13, in driver = Edge(options = edge_options, executable_path = "C:\Users\PopA2\Downloads\edgedriver_win64 (1)\msedgedriver.exe") File "C:\Program Files\Python37\lib\site-packages\msedge\selenium_tools\webdriver.py", line 108, in init desired_capabilities=desired_capabilities) File "C:\Program Files\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "C:\Program Files\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "C:\Program Files\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Program Files\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: MSEdge failed to start: was killed. (unknown error: DevToolsActivePort file doesn't exist) (The process started from msedge location C:\Users\PopA2\Downloads\edgedriver_win64 (1)\msedgedriver.exe is no longer running, so MSEdgeDriver is assuming that MSEdge has crashed.)
Upvotes: 2
Views: 3526
Reputation: 12999
Are you running the program under LocalSystem account? If so, the issue is the same as which mentioned in the comment and this thread.
I suggest that you can provide feedback about this issue to Edge team by pressing Alt+Shift+I in Edge. For now, the only workaround is not to run Edge under LocalSystem account.
Besides, if you want to run Edge with default profile, you can use the below line of code and there's no need to specify profile-directory
. You can also add --remote-debugging-port
argument to fix the issue:
edge_options.add_argument("user-data-dir=C:\\Users\\PopA2\\AppData\\Local\\Microsoft\\Edge\\User Data")
edge_options.add_argument("--remote-debugging-port=9222")
Upvotes: 0
Reputation: 193298
Seems you were close. You need to remove the Default
sub-directory from the path mentioned through user-data-dir
.
Effectively your line of code will be:
edge_options.add_argument("user-data-dir=C:\\Users\\PopA2\\AppData\\Local\\Microsoft\\Edge\\User Data")
Upvotes: 0