Complete the code to close the current browser window.
driver.[1]()The close() method closes the current browser window that the driver is controlling.
Complete the code to close all browser windows and end the WebDriver session.
driver.[1]()The quit() method closes all browser windows and ends the WebDriver session cleanly.
Fix the error in the code to properly close the browser session.
driver.[1]() # closes all windows and ends session
To close all browser windows and end the session, use quit(). Using close() only closes the current window.
Fill both blanks to close the current window and then end the session.
driver.[1]() driver.[2]()
First, close() closes the current window. Then, quit() ends the entire session and closes any remaining windows.
Fill all three blanks to check if the browser has multiple windows, close the current window, and then quit the session.
if len(driver.window_handles) > [1]: driver.[2]() driver.[3]()
This code checks if there is more than one window open (more than 1). If yes, it closes the current window with close(). Finally, it ends the session with quit().