Lo-Fi Python

Aug 15, 2021

Opening Firefox Via the webbrowser Module + RPA Tools

webbrowser is a convenient Python standard library module. It opened my Firefox browser on my Ubuntu Linux operating system running on a Chromebook. This code is adapted from a Python Examples blog post. Below is a list of other browsers you can open with webbrowser. At the bottom of this post, you'll find more tools to interact with browsers and GUIs programmatically.

import webbrowser

firefox_sh = "/usr/lib/firefox/firefox.sh"
webbrowser.register("firefox", None, webbrowser.BackgroundBrowser(firefox_sh))
url = "https://lofipython.com"
webbrowser.get("firefox").open_new_tab(url)
print(webbrowser._browsers)
Type Name Class Name
'mozilla' Mozilla('mozilla')
'firefox' Mozilla('mozilla')
'netscape' Mozilla('netscape')
'galeon' Galeon('galeon')
'epiphany' Galeon('epiphany')
'skipstone' BackgroundBrowser('skipstone')
'kfmclient' Konqueror()
'konqueror' Konqueror()
'kfm' Konqueror()
'mosaic' BackgroundBrowser('mosaic')
'opera' Opera()
'grail' Grail()
'links' GenericBrowser('links')
'elinks' Elinks('elinks')
'lynx' GenericBrowser('lynx')
'w3m' GenericBrowser('w3m')
'windows-default' WindowsDefault
'macosx' MacOSX('default')
'safari' MacOSX('safari')
'google-chrome' Chrome('google-chrome')
'chrome' Chrome('chrome')
'chromium' Chromium('chromium')
'chromium-browser' Chromium('chromium-browser')

webbrowser docs

Check out these other browsergui automation tools:

see also: | Robot Process Automation | Things You Can Do With a Browser in 2020