Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

Python Automation Tutorial to Open Chrome Browser Automatically Using WebBrowser Library

Posted on January 14, 2023

 

 

Welcome folks today in this blog post we will be using the webbrowser library in python to automate chrome browser and open url in it. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to install the below library using the below pip command as shown below

 

 

pip install webbrowser

 

 

And now you need to make an app.py file and copy paste the following code

 

 

app.py

 

 

Python
1
2
3
4
5
import webbrowser
 
# Open the Chrome browser
chrome = webbrowser.get('chrome')
chrome.open_new_tab('https://www.google.com')

 

 

This script first imports the webbrowser library and then uses the get() function to specify that we want to use the Chrome browser. It then uses the open_new_tab() function to open a new tab in Chrome and navigate to the specified URL (in this case, Google.com).

Alternatively, you can also use the open() function instead of open_new_tab() to open the URL in the default browser.

 

 

Python
1
webbrowser.open('https://www.google.com')

 

 

Recent Posts

  • Android Java Project to Merge Multiple PDF Documents From Gallery Using iTextPDF Library
  • Android Java Project to Detect System Hardware & System CPU Info & Display inside TextView Widget
  • Android Java Project to Integrate Google OAuth2 Login & Logout System & Save User Info in SharedPreferences
  • Android Java Project to Export Raw Text to PDF Document Using iTextPDF Library
  • Android Java Project to Export Images From Gallery to PDF Document Using iTextPDF Library
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme