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.
- How to use close() and quit() method in Selenium Python ?
- close driver method - Selenium Python
- Web Driver Methods in Selenium Python
- Python program to crawl a web page and get most frequent words
- Python | Find all close matches of input string from a list
- Python | os.close() method
- response.close() - Python requests
- Matplotlib.pyplot.close() in Python
- How to open and close a file in Python
- Python - Convert Tick-by-Tick data into OHLC (Open-High-Low-Close) Data
- Selenium Base Mini Project Using Python
- Python | SMS Bomber using Selenium
- Non blocking wait in selenium using Python
- Python | Automating Happy Birthday post on Facebook using Selenium
- How to access popup login window in selenium using Python
- Python | Automate Google Search using Selenium
- Python - Opening links using Selenium
- Flight-price checker using Python and Selenium
- How to take screenshot using Selenium in Python ?
- How to get title of a webpage using Selenium in Python?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.