fixed screenshot capture and conversion
This commit is contained in:
+14
-5
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user