Overview - Closing browser (close vs quit)
What is it?
In Selenium WebDriver, closing a browser means stopping the browser window that is currently open. There are two main methods to do this: close() and quit(). The close() method closes the current browser window, while quit() closes all browser windows and ends the WebDriver session. Understanding the difference helps control browser behavior during automated tests.
Why it matters
Without knowing the difference between close() and quit(), tests may leave browser windows open or sessions running, causing resource leaks and flaky tests. This can slow down test execution and cause failures that are hard to diagnose. Properly closing browsers ensures clean test environments and reliable automation.
Where it fits
Before learning this, you should understand basic Selenium WebDriver setup and how to open browsers. After this, you can learn about managing browser sessions, handling multiple windows or tabs, and optimizing test cleanup.