driver.close()
: This command is used to close the current browser window that the WebDriver is focused on. If there’s only one window open, the entire browser session will terminate.
driver.quit()
: This command is used to close all windows and tabs opened by the WebDriver session. It’s crucial for cleaning up and ensuring that the browser process is terminated completely, preventing memory leaks and orphaned processes. It is highly recommended to use driver.quit()
in the @AfterTest
or @AfterMethod
methods of your test framework.