How to start Microsoft Edge from Python script using webbrowser
Asked Answered
S

5

7

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)\Google\Chrome\Application\chrome.exe"
edge_path="C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.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')
Schleswig answered 11/6, 2020 at 7:47 Comment(1)
I read somewhere that Edge can't be started by running the exe, it is "different".Reposition
G
10

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

C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe

Gelatinize answered 17/3, 2021 at 19:53 Comment(0)
B
2

import os

os.startfile("msedge")

Blackpoll answered 13/3, 2022 at 6:21 Comment(2)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Traci
This helped me with my problem, thanx. Up until now I was trying subprocess.Popen(["msedge"]) which did not work.Subsidize
B
1

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

Baptism answered 29/11, 2020 at 13:57 Comment(0)
G
1

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

Guadalquivir answered 2/12, 2020 at 14:34 Comment(0)
K
0

Instead of:

edge_path="C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe

try:

edge_path="C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\msedge.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.

Kautz answered 26/7, 2022 at 2:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.