What is close() and quit() commands in Selenium Webdriver?
https://www.zyxware.com/sites/default/files/styles/user_image/public/default_images/index.png?itok=2YmREnrP
BY Urmila.cm
3 years ago
Software-Testing
0 comments comment

In Selenium Webdriver, a browser session can be closed using two webdriver commands: close() and quit(). The situations in which they are used are briefly explained below:

close()

close() is a webdriver command which closes the browser window which is currently in focus.

During the automation process, if there are more than one browser window opened, then the close() command will close only the current browser window which is having focus at that time. The remaining browser windows will not be closed. The following code can be used to close the current browser window:

driver.close() //where, ‘driver’ is the Webdriver object.

quit()

quit() is a webdriver command which calls the driver.dispose method, which in turn closes all the browser windows and terminates the WebDriver session. If we do not use quit() at the end of program, the WebDriver session will not be closed properly and the files will not be cleared off memory. This may result in memory leak errors.

The following code can be used to close all the browser windows:

driver.quit()   //where, ‘driver’ is the Webdriver object.

If the Automation process opens only a single browser window, the close() and quit() commands work in the same way. Both will differ in their functionality when there are more than one browser window opened during Automation.

Hope you find this tips useful. Please feel free to get in touch with us for any queries.


RELATED ARTICLE

/themes/custom/zyxpro_light/images/placeholder.png
close

on 30th May 2012 / by anju.r
A software bug is defined as an error or failure or fault in a system or computer program that produces an unexpected or incorrect result. This is applicable for any Drupal/non-Drupal website. The bug life cycle in a Drupal website consists of steps from identification to closure of a bug. Different stages of Bug Life Cycle are: Drupal Software Testing Leave a reply Your email address will not be published. Required fields are marked *
Leave a reply
Your email address will not be published. Required fields are marked *

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
The content of this field is kept private and will not be shown publicly.
CAPTCHA This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.