1) WebDriver.Close() This method is used to close the current open window. It closes the current open window on which driver has focus on. If Suppose your Webdriver has opened more than one browser window, if you use driver.close(); then, it will close only 1 browser window on which driver is focused currently.
2) WebDriver.Quit() This method is used to destroy the instance of WebDriver. It closes all Browser Windows associated with that driver and safely ends the session. WebDriver.Quit() calls Dispose. If Suppose your Webdriver has opened more than one browser window, if you use driver.quit(); then, it will close all browser windows which are opened by that driver.
3) WebDriver.Dispose() This method closes all Browser windows and safely ends the session
package com.aayushCorp.utilities; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; public class LoginToAayushCorp { WebDriver driver; @BeforeMethod public void Login() throws Exception { driver =new FirefoxDriver(); driver.navigate().to("https://www.google.co.i"); driver.manage().window().maximize(); } @AfterMethod public void TearDown(){ driver.close(); driver.quit(); } }