i have created a selenium script in maven java, it opens a website and do some tasks, and sometimes it opens Firefox in one more new window automatically. so i want to handle such situation by closing all windows of Firefox. as you know driver.close(); will only close one focused window, so i replaced driver.close(); with driver.dispose(); to close all Firefox windows but it shows error in eclipse
The method dispose() is undefined for the type WebDriver
and i think no need to add my code here, because my question is how can i close all windows of Firefox? or how to use driver.dispose() ? Thanks
Use the .quit()
method instead:
void quit()
Quits this driver, closing every associated window.
driver.quit();