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

Method screenshot

playwright/_impl/_page.py:795–835  ·  view source on GitHub ↗
(
        self,
        timeout: float = None,
        type: Literal["jpeg", "png"] = None,
        path: Union[str, Path] = None,
        quality: int = None,
        omitBackground: bool = None,
        fullPage: bool = None,
        clip: FloatRect = 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

793 )
794
795 async def screenshot(
796 self,
797 timeout: float = None,
798 type: Literal["jpeg", "png"] = None,
799 path: Union[str, Path] = None,
800 quality: int = None,
801 omitBackground: bool = None,
802 fullPage: bool = None,
803 clip: FloatRect = None,
804 animations: Literal["allow", "disabled"] = None,
805 caret: Literal["hide", "initial"] = None,
806 scale: Literal["css", "device"] = None,
807 mask: Sequence["Locator"] = None,
808 maskColor: str = None,
809 style: str = None,
810 ) -> bytes:
811 params = locals_to_params(locals())
812 if "path" in params:
813 if "type" not in params:
814 params["type"] = determine_screenshot_type(params["path"])
815 del params["path"]
816 if "mask" in params:
817 params["mask"] = list(
818 map(
819 lambda locator: (
820 {
821 "frame": locator._frame._channel,
822 "selector": locator._selector,
823 }
824 ),
825 params["mask"],
826 )
827 )
828 encoded_binary = await self._channel.send(
829 "screenshot", self._timeout_settings.timeout, params
830 )
831 decoded_binary = base64.b64decode(encoded_binary)
832 if path:
833 make_dirs_for_file(path)
834 await async_writefile(path, decoded_binary)
835 return decoded_binary
836
837 async def title(self) -> str:
838 return await self._main_frame.title()

Calls 5

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