Software Testing

Command to close the current browser window?

Command to close the current browser window in Selenium WebDriver?

a. driver.quit()

b. driver.close()

c. driver.stop()

d. driver.exit()

Correct Answer

b. driver.close()

Explanation

The driver.close() command closes the current browser window that the WebDriver is controlling. If multiple windows are open, it will only close the one currently in focus.

The driver.quit() command, on the other hand, closes all browser windows and ends the WebDriver session.