python playwright 不自动关闭浏览器
时间: 2023-10-10 21:08:56 浏览: 656
Playwright _ API.pdf
当使用 python playwright 完成网页自动化任务后,浏览器通常会自动关闭,如果需要保持浏览器窗口打开,可以在启动时添加参数 headless=False,例如:
```python
from playwright.sync_api import Playwright, sync_playwright
with sync_playwright() as playwright:
browser = playwright.chromium.launch(headless=False)
page = browser.new_page()
# 执行自动化任务
browser.close()
```
这样,执行完成后浏览器窗口就会一直保持打开状态。
阅读全文