Selenium webdriver close and quit Difference of these methods

Table of Contents

1. In Selenium WebDriver, what does the close() method do?

A. Closes all browser windows
B. Closes the current browser window
C. Quits the WebDriver session
D. Minimizes the browser window

Answer: B

2. What does the quit() method do in Selenium WebDriver?

A. Closes the current tab
B. Ends the entire browser session and closes all windows
C. Refreshes the browser
D. Deletes all cookies

Answer: B

3. Which is safer to use at the end of a test suite?

A. driver.close()
B. driver.quit()
C. Both
D. None

Answer: B

4. What happens if you call driver.close() when multiple browser tabs are open?

A. All tabs are closed
B. Only the active tab is closed
C. Browser crashes
D. It throws an exception

Answer: B

5. In Selenium WebDriver close and quit comparison, which one ends the session ID?

A. close()
B. quit()
C. Both
D. Neither

Answer: B

6. After calling driver.quit(), what happens if you try to perform another operation?

A. It executes normally
B. Throws NoSuchSessionException
C. Browser reopens
D. Test restarts

Answer: B

7. Which Selenium WebDriver close and quit method should you use when running multiple browsers in parallel?

A. Always use close()
B. Always use quit()
C. Use close() for specific windows and quit() at the end
D. Neither

Answer: C

8. What is the main difference between close() and quit()?

A. close() closes one window; quit() closes all windows and ends the session
B. Both close all windows
C. quit() minimizes browser
D. No difference

Answer: A

9. In Selenium WebDriver, when should you prefer close() over quit()?

A. When handling multiple windows manually
B. When ending the complete test
C. When terminating the browser session
D. When clearing cookies

Answer: A

10. What will happen if you call close() twice in a row?

A. Closes two windows
B. Throws NoSuchWindowException on second call
C. Closes entire session
D. Restarts browser

Answer: B


11. Which Selenium WebDriver close and quit method is typically used in @AfterSuite in TestNG?

A. driver.close()
B. driver.quit()
C. driver.end()
D. driver.destroy()

Answer: B

12. What is a common mistake new testers make with close() and quit()?

A. Using quit() before switching tabs
B. Using close() expecting to end the session
C. Using both in a single test method
D. Forgetting to call them at all

Answer: B

13. Which command is faster when exiting Selenium WebDriver?

A. driver.close()
B. driver.quit()
C. Both are same
D. Depends on OS

Answer: A

14. When using RemoteWebDriver, which method actually ends the session on the server?

A. close()
B. quit()
C. terminate()
D. dispose()

Answer: B

15. What is the primary impact of using close() incorrectly?

A. Memory leaks
B. Orphaned browser sessions
C. Test crashes
D. Invalid test data

Answer: B

16. In Selenium WebDriver close and quit analysis, which method helps release driver memory completely?

A. close()
B. quit()
C. Both
D. None

Answer: B

17. What happens if you forget to call quit() at the end of your test?

A. Browser stays open in the background
B. Test fails immediately
C. WebDriver automatically closes browser
D. Nothing

Answer: A

18. Which of the following Selenium WebDriver close and quit statements is best practice?

A. Use close() in every test
B. Always use quit() at the end of the suite
C. Avoid both for stability
D. Use both in same test

Answer: B

19. Which exception confirms that the browser session has already been closed?

A. SessionNotFoundException
B. NoSuchSessionException
C. WindowNotFoundException
D. SessionTerminatedException

Answer: B

20. Why is understanding Selenium WebDriver close and quit difference important?

A. For writing reusable code
B. For avoiding resource leaks
C. For stable test execution
D. All of the above

Answer: D

Share this article

Enroll Free demo class
Enroll IT Courses

Enroll Free demo class

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Join Free Demo Class

Let's have a chat