1. 浏览器启动时,加参数 args=['--start-maximized']
;
2. 创建上下文时,加参数 no_viewport=True
。
from playwright.sync_api import Playwright, sync_playwright
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False, args=['--start-maximized'])
context = browser.new_context(no_viewport=True)
page = context.new_page()
page.goto("https://playwright.dev/")
page.wait_for_timeout(10*1000)
# ---------------------
context.close()
browser.close()
with sync_playwright() as playwright:
run(playwright)
再运行,就可以飞起来啦~~~
有图有真相!窗口已是最大化!
Life is great and everything will be OK, huajianketang is here.
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。