如何在不关闭浏览器的情况下关闭浏览器窗口?

2024-04-16 12:42:20 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在不关闭webdriver中的浏览器的情况下关闭浏览器窗口?我有点像

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

当然,此时我可以再次执行driver = webdriver.Firefox(),但是有没有办法在不退出浏览器的情况下关闭窗口?谢谢!


Tags: fromimportcomhttpgetsowwwdriver