Python selenium 执行代码后关闭chrome浏览器

时间:2020-12-20 14:05:45

标签: selenium

Python selenium 在执行代码后关闭 Chrome 浏览器。

下面是我的代码。

可以打开chrome浏览器,执行后自动关闭窗口。

from selenium import webdriver
browser = webdriver.Chrome()
browser.get("https://www.google.com/")

还尝试了以下来自其他“问答”的代码,但不起作用。

from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)

有没有办法在执行后保持窗口打开?

在最后添加“input()”有效,但还有其他解决方案吗?

谢谢。

0 个答案:

没有答案
相关问题