How to use close() and quit() method in Selenium Python ? Improve Improve Like Article Like Save Share Report While doing stuff with selenium multiple browsers with multiple tabs will normally opens in order to close these tabs close() and quit() methods are used. close() method is used to close the current browser window on which the focus is set, on the other hand quit() method essentially calls the driver.dispose method that successively closes all the browser windows and ends the WebDriver session graciously. Syntax : driver.close() driver.quit() Argument : Both methods takes no argument Action performed : close() method closes the current window. quit() method quits the driver instance, closing every associated window, which is opened. Code for close method() : # importing webdriver from selenium from selenium import webdriver # Here Chrome will be used driver = webdriver.Chrome() # URL of website url = "https://www.geeksforgeeks.org/" # Opening the website driver.get(url) # Closes the current window driver.close() Output : The webpage will loaded then closes due to close() method. Code for quit() method: # importing webdriver from selenium from selenium import webdriver # Here Chrome will be used driver = webdriver.Chrome() # URL of website url = "https://www.geeksforgeeks.org/" # Opening the website driver.get(url) # All windows related to driver instance will quit driver.quit() Output : The webpage will be loaded then window get quit due to quit() method. Last Updated : 06 Mar, 2020 Like Article Save Article Previous How to handle Frames/iFrames in Selenium with Python Next How to get title of a webpage using Selenium in Python? Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads quit driver method - Selenium Python close driver method - Selenium Python Python exit commands: quit(), exit(), sys.exit() and os._exit() Close specific Web page using Selenium in Python How to use Selenium Web Driver and JavaScript to Login any website ? Python | os.close() method How to open and close a file in Python Javascript Window Open() & Window Close() Method HTML DOM close() Method jQWidgets jqxDropDownButton close() Method Like R rakshitarora Follow Article Tags : Python-selenium Python Web Technologies Practice Tags : python