Selenium is a powerful tool for controlling web browsers through programs and performing browser automation. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python.
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.
- Import required modules
- Taking any URL.
- We want the child window of this web page then click on any button.
- Copy XPath.
- Use the find_element_by_xpath() method to find XPath.
- Create a handles variable who store all handles value of the open browser window.
- Then the specified condition of the closing web page.
The close() method closes current window page. Some pages are used for a long time some pages used for short time. If we want to close a specific web page, we need to use some condition.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course