I have opened a webbrowser window using webbrowser.open(url)
in python now I want to close the webbrowser opened using python. Is it possible to do so?
The close() method is a web driver command which closes the browser window. During the automation process, if there are multiple browser windows opened, then the close() command will close the current browser window that is having attention at that time.
A. The procedure for closing all open Chrome browser tabs has changed over the years, but on most recent Android tablets, press down on the “x” on the end of any open tab. Leave your finger on the tab until the Close All Tabs option appears on screen and then select that option to shut down all of the open pages.
Method 3: Using quit() method Or, you can use exit() function after mainloop to exit from the Python program.
For MacOS, you can use below command:
os.system("killall -9 'Google Chrome'")
There is no webbrowser.close, you can use these codes to close the task(in Windows OS):
First Import os package with
import os
then use system function to kill the task
os.system("taskkill /im firefox.exe /f")
os.system("taskkill /im chrome.exe /f")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With