Close Browser

To close a browser we need to call close() method from webdriver, we can also work without closing a browser (i.e) we can open another browser instance without closing existing browser but existing browser takes little space.


						import org.openqa.selenium.WebDriver;
						import org.openqa.selenium.firefox.FirefoxDriver;

						public class CloseBrowser 
						{
							public static void main(String[] args) throws Exception 
							{
								WebDriver driver=new FirefoxDriver();
								driver.close(); //closes the browser
							}
						}
					

Quit Browser

To close a browser window we need to call close() method from webdriver, but what if we want to close all browser windows opened by current instance. To Close all windows we need to call quit() method from webdriver


						import org.openqa.selenium.WebDriver;
						import org.openqa.selenium.firefox.FirefoxDriver;

						public class QuitBrowser 
						{
							public static void main(String[] args) throws Exception 
							{
								WebDriver driver=new FirefoxDriver();
								driver.quit(); //closes all browser windows
							}
						}
					

 
Join My Facebook Group
Join Group
 

About Author

Myself KarthiQ, I am the author of this blog, I know ways to write a good article but some how I donot have the skills to make it to reach people, would you like help me to reach more people By sharing this Article in the social media.

Share this Article Facebook
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions
Copyright © CherCher Tech