How to start Microsoft Edge from Python script using webbrowser

Question:

Using webbrowser lib, I can start both Chrome and Firefox from a python script. It fails for Edge. I noticed ways to start Edge using webdriver but my question here is if it is possible to use the following script for edge. It currently starts Chrome only.

import webbrowser

chrome_path="C:Program Files (x86)GoogleChromeApplicationchrome.exe"
edge_path="C:WindowsSystemAppsMicrosoft.MicrosoftEdge_8wekyb3d8bbweMicrosoftEdge.exe"

webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chrome_path))
webbrowser.register('edge', None, webbrowser.BackgroundBrowser(edge_path))

webbrowser.get('chrome').open('http://www.google.com')
webbrowser.get('edge').open('http://www.microsoft.com')
Asked By: Kayle199

||

Answers:

Maybe your path is wrong. Run edge and start task manager. Select edge browser, right click and select ‘open file location'(Maybe you can see this name different in task manager bcs I used translate) and then copy the path. set edge_path to this but you should add the file name. For example my edge’s exe file’s name is ‘msedge.exe’ dont forget to add this at the and of the path

Answered By: SukruGokk

Your implementation plus this answer helped me to open Edge on Linux. Maybe it will help you on Windows also.

Cant speak for your version of Windows, but in the latest, the edge filepath is

C:Program Files (x86)MicrosoftEdgeApplicationmsedge.exe

Answered By: CurtisG

import os

os.startfile("msedge")

Answered By: Rajat NIshad

Instead of:

edge_path="C:WindowsSystemAppsMicrosoft.MicrosoftEdge_8wekyb3d8bbweMicrosoftEdge.exe

try:

edge_path="C:WindowsSystemAppsMicrosoft.MicrosoftEdge_8wekyb3d8bbwemsedge.exe

That’s what worked for me atleast
And if not then go to program files, select edge and press the .exe files properties and copy the path from there.

Answered By: Void_Unlocked
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.