Tuesday 29 October 2013

How to close the browser window in selenium webdriver in Java?

Below example shows how we can close the browser window in java using selenium web driver

WebDriver driver = new FirefoxDriver();
driver.close();
driver.quit();

Please note that same code will work on all other browsers like chrome, safari and IE. Notice that same code can be used to close the tabs as well. A tab in browser is considered as a new browser window in Selenium.

You may also like to read below topics.
  1. Press key in Selenium Webdriver in Java
  2. Read Table Data in Selenium Webdriver in Java
  3. Take the screenshot in Selenium Webdriver in Java
  4. Execute JavaScript in Selenium Webdriver in Java
  5. Handle multiple browser windows in Selenium Webdriver in Java
  6. Double-Click on the Element in Selenium Webdriver in Java
  7. Exceptions in Selenium Webdriver in Java
  8. Synchronization in Selenium Webdriver in Java

What do you think on above selenium topic. Please provide your inputs and comments. Thanks

No comments:

Post a Comment

Buy Best Selenium Books

Contributors