Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I close the browser window without closing the browser?

How can I close the browser window without closing the browser in webdriver? I have something like

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.google.com")
# so far so good

driver.close()
# quits the app altogether :(

driver.get("http://www.google.com")
# doesn't do anything

Of course I can do driver = webdriver.Firefox() again at this point, but is there a way to just close the window without quitting the browser? Thanks!

like image 721
ceiling cat Avatar asked Dec 05 '25 02:12

ceiling cat


1 Answers

Use driver.get(""); instead of driver.close();.

like image 183
lamachok Avatar answered Dec 07 '25 17:12

lamachok