Closing the Tab using Selenium
In order to close the tab, .close() method is used.
Python3
# Import module from selenium import webdriver # Create object driver = webdriver.Chrome() # Fetching the Url # Opening first url driver.get(url) # Closing the tab driver.close() |
Output:
Opening and Closing Tabs Using Selenium
Selenium is a tool which is used to automate browser instructions. It is utilitarian for all programs, deals with all significant OS and its contents are written in different languages i.e Python, Java, C# etc.
In this article, we are using Python as the language and Chrome as the WebDriver.
Installation
Python selenium module can be installed using the below command:
pip install selenium
Chrome Driver can be downloaded from Chrome Driver (version == 87.0.4).