What is the difference between driver.close() and driver.quit() in Selenium WebDriver?

1 Answers
Answered by suresh

Key Answer: Difference between driver.close() and driver.quit() in Selenium WebDriver

Difference between driver.close() and driver.quit() in Selenium WebDriver

The focus keyword for this topic is Selenium WebDriver methods.

When working with Selenium WebDriver, it is essential to understand the distinction between driver.close() and driver.quit() methods.

driver.close():

The driver.close() method is used to close the current browser window or tab that the WebDriver is currently controlling. It does not shut down the entire WebDriver instance, allowing you to continue using other windows or tabs opened by the WebDriver.

driver.quit():

On the other hand, driver.quit() is used to shut down the entire WebDriver instance along with all browser windows and tabs that were opened by the WebDriver. This method effectively ends the WebDriver session and releases all associated resources.

Therefore, the key difference between driver.close() and driver.quit() is that driver.close() closes a single window/tab, while driver.quit() exits the entire WebDriver session.

Answer for Question: What is the difference between driver.close() and driver.quit() in Selenium WebDriver?