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.
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).
Opening a Tab Using Selenium
In order to open a tab, a web driver is needed. In this, we are using Chrome Webdriver. After providing the driver path, use .get(URL) method to open a tab.
Opening a New tab using Selenium
Closing the Tab using Selenium:
In order to close the tab, .close() method is used.
Closing a Tab and switching to a new Tab using Selenium:
In the case of multiple tabs, after closing the tab using .close() method we can switch to the tab which is not closed using .switch_to_window() method.