fixed screenshot capture and conversion

This commit is contained in:
2026-04-21 11:35:37 -07:00
parent 10e3cd009b
commit bc95a5c45d
2 changed files with 271 additions and 43 deletions
+14 -5
View File
@@ -274,6 +274,8 @@ class PlaywrightTool:
viewport_height: Optional[int] = None,
ignore_https_errors: Optional[bool] = None,
accept_downloads: bool = False,
emulate_viewport: bool = True,
start_maximized: bool = False,
) -> Iterator[Any]:
"""Context manager yielding a Playwright page with sane defaults."""
self.require()
@@ -314,19 +316,26 @@ class PlaywrightTool:
if browser_type is None:
browser_type = pw.chromium
launch_args = ["--disable-blink-features=AutomationControlled"]
if bool(start_maximized) and not h:
launch_args.append("--start-maximized")
browser = browser_type.launch(
headless=h,
args=["--disable-blink-features=AutomationControlled"],
args=launch_args,
)
context_kwargs: Dict[str,
Any] = {
"viewport": {
"width": vw,
"height": vh
},
"ignore_https_errors": ihe,
"accept_downloads": bool(accept_downloads),
}
if bool(emulate_viewport):
context_kwargs["viewport"] = {
"width": vw,
"height": vh,
}
else:
context_kwargs["no_viewport"] = True
if ua_value is not None:
context_kwargs["user_agent"] = ua_value