MCPcopy Index your code
hub / github.com/microsoft/playwright-python / screenshot

Method screenshot

playwright/_impl/_element_handle.py:313–351  ·  view source on GitHub ↗
(
        self,
        timeout: float = None,
        type: Literal["jpeg", "png"] = None,
        path: Union[str, Path] = None,
        quality: int = None,
        omitBackground: bool = None,
        animations: Literal["allow", "disabled"] = None,
        caret: Literal["hide", "initial"] = None,
        scale: Literal["css", "device"] = None,
        mask: Sequence["Locator"] = None,
        maskColor: str = None,
        style: str = None,
    )

Source from the content-addressed store, hash-verified

311 return await self._channel.send("boundingBox", None)
312
313 async def screenshot(
314 self,
315 timeout: float = None,
316 type: Literal["jpeg", "png"] = None,
317 path: Union[str, Path] = None,
318 quality: int = None,
319 omitBackground: bool = None,
320 animations: Literal["allow", "disabled"] = None,
321 caret: Literal["hide", "initial"] = None,
322 scale: Literal["css", "device"] = None,
323 mask: Sequence["Locator"] = None,
324 maskColor: str = None,
325 style: str = None,
326 ) -> bytes:
327 params = locals_to_params(locals())
328 if "path" in params:
329 if "type" not in params:
330 params["type"] = determine_screenshot_type(params["path"])
331 del params["path"]
332 if "mask" in params:
333 params["mask"] = list(
334 map(
335 lambda locator: (
336 {
337 "frame": locator._frame._channel,
338 "selector": locator._selector,
339 }
340 ),
341 params["mask"],
342 )
343 )
344 encoded_binary = await self._channel.send(
345 "screenshot", self._frame._timeout, params
346 )
347 decoded_binary = base64.b64decode(encoded_binary)
348 if path:
349 make_dirs_for_file(path)
350 await async_writefile(path, decoded_binary)
351 return decoded_binary
352
353 async def query_selector(self, selector: str) -> Optional["ElementHandle"]:
354 return from_nullable_channel(

Callers

nothing calls this directly

Calls 5

locals_to_paramsFunction · 0.90
make_dirs_for_fileFunction · 0.90
async_writefileFunction · 0.90
sendMethod · 0.45

Tested by

no test coverage detected