ceiling cat
ceiling cat

Reputation: 5701

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!

Upvotes: 3

Views: 5301

Answers (1)

lamachok
lamachok

Reputation: 116

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

Upvotes: 10

Related Questions