Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start Microsoft Edge from Python script using webbrowser

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')
like image 244
Kayle199 Avatar asked Jul 19 '26 20:07

Kayle199


1 Answers

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

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

like image 121
CurtisG Avatar answered Jul 21 '26 08:07

CurtisG