コード例 #1
0
ファイル: _page.py プロジェクト: tipiqi/playwright-python
 async def setContent(
     self,
     html: str,
     timeout: int = None,
     waitUntil: DocumentLoadState = None,
 ) -> None:
     return await self._main_frame.setContent(**locals_to_params(locals()))
コード例 #2
0
 async def waitForSelector(
     self,
     selector: str,
     timeout: int = None,
     state: Literal["attached", "detached", "hidden", "visible"] = None,
 ) -> Optional[ElementHandle]:
     return await self._main_frame.waitForSelector(**locals_to_params(locals()))
コード例 #3
0
 async def launch(
     self,
     executablePath: Union[str, Path] = None,
     args: List[str] = None,
     ignoreDefaultArgs: Union[bool, List[str]] = None,
     handleSIGINT: bool = None,
     handleSIGTERM: bool = None,
     handleSIGHUP: bool = None,
     timeout: int = None,
     env: Env = None,
     headless: bool = None,
     devtools: bool = None,
     proxy: ProxySettings = None,
     downloadsPath: Union[str, Path] = None,
     slowMo: int = None,
     chromiumSandbox: bool = None,
     firefoxUserPrefs: Dict[str, Union[str, int, bool]] = None,
 ) -> Browser:
     params = locals_to_params(locals())
     normalize_launch_params(params)
     try:
         return from_channel(await self._channel.send("launch", params))
     except Exception as e:
         if f"{self.name}-" in str(e):
             raise not_installed_error(
                 f'"{self.name}" browser was not found.')
         raise e
コード例 #4
0
ファイル: _page.py プロジェクト: tipiqi/playwright-python
 async def pdf(
     self,
     scale: int = None,
     displayHeaderFooter: bool = None,
     headerTemplate: str = None,
     footerTemplate: str = None,
     printBackground: bool = None,
     landscape: bool = None,
     pageRanges: str = None,
     format: str = None,
     width: Union[str, float] = None,
     height: Union[str, float] = None,
     preferCSSPageSize: bool = None,
     margin: PdfMargins = None,
     path: Union[str, Path] = None,
 ) -> bytes:
     params = locals_to_params(locals())
     if "path" in params:
         del params["path"]
     encoded_binary = await self._channel.send("pdf", params)
     decoded_binary = base64.b64decode(encoded_binary)
     if path:
         with open(path, "wb") as fd:
             fd.write(decoded_binary)
     return decoded_binary
コード例 #5
0
 async def waitForNavigation(
     self,
     url: URLMatch = None,
     waitUntil: DocumentLoadState = None,
     timeout: int = None,
 ) -> Optional[Response]:
     return await self._main_frame.waitForNavigation(**locals_to_params(locals()))
コード例 #6
0
ファイル: _frame.py プロジェクト: tipiqi/playwright-python
 async def setContent(
     self,
     html: str,
     timeout: int = None,
     waitUntil: DocumentLoadState = None,
 ) -> None:
     await self._channel.send("setContent", locals_to_params(locals()))
コード例 #7
0
 async def waitForElementState(
     self,
     state: Literal["disabled", "enabled", "hidden", "stable", "visible"],
     timeout: int = None,
 ) -> None:
     await self._channel.send("waitForElementState",
                              locals_to_params(locals()))
コード例 #8
0
ファイル: _page.py プロジェクト: tipiqi/playwright-python
 async def dispatchEvent(self,
                         selector: str,
                         type: str,
                         eventInit: Dict = None,
                         timeout: int = None) -> None:
     return await self._main_frame.dispatchEvent(
         **locals_to_params(locals()))
コード例 #9
0
ファイル: _page.py プロジェクト: tipiqi/playwright-python
 async def goForward(
     self,
     timeout: int = None,
     waitUntil: DocumentLoadState = None,
 ) -> Optional[Response]:
     return from_nullable_channel(await self._channel.send(
         "goForward", locals_to_params(locals())))
コード例 #10
0
 async def snapshot(self,
                    interestingOnly: bool = None,
                    root: ElementHandle = None) -> Optional[Dict]:
     params = locals_to_params(locals())
     if root:
         params["root"] = root._channel
     result = await self._channel.send("accessibilitySnapshot", params)
     return _ax_node_from_protocol(result) if result else None
コード例 #11
0
 async def setInputFiles(
     self,
     selector: str,
     files: Union[str, FilePayload, List[str], List[FilePayload]],
     timeout: int = None,
     noWaitAfter: bool = None,
 ) -> None:
     return await self._main_frame.setInputFiles(**locals_to_params(locals()))
コード例 #12
0
 async def addScriptTag(
     self,
     url: str = None,
     path: Union[str, Path] = None,
     content: str = None,
     type: str = None,
 ) -> ElementHandle:
     return await self._main_frame.addScriptTag(**locals_to_params(locals()))
コード例 #13
0
 async def hover(
     self,
     modifiers: List[KeyboardModifier] = None,
     position: Tuple[float, float] = None,
     timeout: int = None,
     force: bool = None,
 ) -> None:
     await self._channel.send("hover", locals_to_params(locals()))
コード例 #14
0
 async def type(
     self,
     text: str,
     delay: int = None,
     timeout: int = None,
     noWaitAfter: bool = None,
 ) -> None:
     await self._channel.send("type", locals_to_params(locals()))
コード例 #15
0
ファイル: _page.py プロジェクト: tipiqi/playwright-python
 async def uncheck(
     self,
     selector: str,
     timeout: int = None,
     force: bool = None,
     noWaitAfter: bool = None,
 ) -> None:
     return await self._main_frame.uncheck(**locals_to_params(locals()))
コード例 #16
0
ファイル: _frame.py プロジェクト: tipiqi/playwright-python
 async def uncheck(
     self,
     selector: str,
     timeout: int = None,
     force: bool = None,
     noWaitAfter: bool = None,
 ) -> None:
     await self._channel.send("uncheck", locals_to_params(locals()))
コード例 #17
0
ファイル: _page.py プロジェクト: tipiqi/playwright-python
 async def goto(
     self,
     url: str,
     timeout: int = None,
     waitUntil: DocumentLoadState = None,
     referer: str = None,
 ) -> Optional[Response]:
     return await self._main_frame.goto(**locals_to_params(locals()))
コード例 #18
0
ファイル: _page.py プロジェクト: tipiqi/playwright-python
 async def close(self, runBeforeUnload: bool = None) -> None:
     try:
         await self._channel.send("close", locals_to_params(locals()))
         if self._owned_context:
             await self._owned_context.close()
     except Exception as e:
         if not is_safe_close_error(e):
             raise e
コード例 #19
0
 async def selectOption(
     self, values: "ValuesToSelect", timeout: int = None, noWaitAfter: bool = None
 ) -> List[str]:
     params = locals_to_params(locals())
     if "values" in params:
         values = params.pop("values")
         params = {**params, **convert_select_option_values(values)}
     return await self._channel.send("selectOption", params)
コード例 #20
0
 async def waitForSelector(
     self,
     selector: str,
     state: Literal["attached", "detached", "hidden", "visible"] = None,
     timeout: int = None,
 ) -> Optional["ElementHandle"]:
     return from_nullable_channel(await self._channel.send(
         "waitForSelector", locals_to_params(locals())))
コード例 #21
0
 async def tap(
     self,
     modifiers: List[KeyboardModifier] = None,
     position: MousePosition = None,
     timeout: int = None,
     force: bool = None,
     noWaitAfter: bool = None,
 ) -> None:
     await self._channel.send("tap", locals_to_params(locals()))
コード例 #22
0
ファイル: _frame.py プロジェクト: tipiqi/playwright-python
 async def press(
     self,
     selector: str,
     key: str,
     delay: int = None,
     timeout: int = None,
     noWaitAfter: bool = None,
 ) -> None:
     await self._channel.send("press", locals_to_params(locals()))
コード例 #23
0
 async def setInputFiles(
     self,
     files: Union[str, Path, FilePayload, List[str], List[Path], List[FilePayload]],
     timeout: int = None,
     noWaitAfter: bool = None,
 ) -> None:
     params = locals_to_params(locals())
     params["files"] = normalize_file_payloads(files)
     await self._channel.send("setInputFiles", params)
コード例 #24
0
ファイル: _page.py プロジェクト: tipiqi/playwright-python
 async def press(
     self,
     selector: str,
     key: str,
     delay: int = None,
     timeout: int = None,
     noWaitAfter: bool = None,
 ) -> None:
     return await self._main_frame.press(**locals_to_params(locals()))
コード例 #25
0
ファイル: _page.py プロジェクト: tipiqi/playwright-python
 async def type(
     self,
     selector: str,
     text: str,
     delay: int = None,
     timeout: int = None,
     noWaitAfter: bool = None,
 ) -> None:
     return await self._main_frame.type(**locals_to_params(locals()))
コード例 #26
0
ファイル: _page.py プロジェクト: tipiqi/playwright-python
 async def hover(
     self,
     selector: str,
     modifiers: List[KeyboardModifier] = None,
     position: Tuple[float, float] = None,
     timeout: int = None,
     force: bool = None,
 ) -> None:
     return await self._main_frame.hover(**locals_to_params(locals()))
コード例 #27
0
 async def click(
     self,
     x: float,
     y: float,
     delay: int = None,
     button: MouseButton = None,
     clickCount: int = None,
 ) -> None:
     await self._channel.send("mouseClick", locals_to_params(locals()))
コード例 #28
0
ファイル: _frame.py プロジェクト: tipiqi/playwright-python
 async def tap(
     self,
     selector: str,
     modifiers: List[KeyboardModifier] = None,
     position: Tuple[float, float] = None,
     timeout: int = None,
     force: bool = None,
     noWaitAfter: bool = None,
 ) -> None:
     await self._channel.send("tap", locals_to_params(locals()))
コード例 #29
0
 async def tap(
     self,
     selector: str,
     modifiers: List[KeyboardModifier] = None,
     position: MousePosition = None,
     timeout: int = None,
     force: bool = None,
     noWaitAfter: bool = None,
 ) -> None:
     return await self._main_frame.tap(**locals_to_params(locals()))
コード例 #30
0
 async def launchPersistentContext(
     self,
     userDataDir: Union[str, Path],
     executablePath: Union[str, Path] = None,
     args: List[str] = None,
     ignoreDefaultArgs: Union[bool, List[str]] = None,
     handleSIGINT: bool = None,
     handleSIGTERM: bool = None,
     handleSIGHUP: bool = None,
     timeout: int = None,
     env: Env = None,
     headless: bool = None,
     devtools: bool = None,
     proxy: ProxySettings = None,
     downloadsPath: Union[str, Path] = None,
     slowMo: int = None,
     viewport: Union[Tuple[int, int], Literal[0]] = None,
     ignoreHTTPSErrors: bool = None,
     javaScriptEnabled: bool = None,
     bypassCSP: bool = None,
     userAgent: str = None,
     locale: str = None,
     timezoneId: str = None,
     geolocation: Geolocation = None,
     permissions: List[str] = None,
     extraHTTPHeaders: Dict[str, str] = None,
     offline: bool = None,
     httpCredentials: HttpCredentials = None,
     deviceScaleFactor: int = None,
     isMobile: bool = None,
     hasTouch: bool = None,
     colorScheme: ColorScheme = None,
     acceptDownloads: bool = None,
     chromiumSandbox: bool = None,
     recordHar: RecordHarOptions = None,
     recordVideo: RecordVideoOptions = None,
 ) -> BrowserContext:
     userDataDir = str(Path(userDataDir))
     params = locals_to_params(locals())
     if viewport == 0:
         del params["viewport"]
         params["noDefaultViewport"] = True
     if extraHTTPHeaders:
         params["extraHTTPHeaders"] = serialize_headers(extraHTTPHeaders)
     normalize_launch_params(params)
     try:
         context = from_channel(await self._channel.send(
             "launchPersistentContext", params))
         context._options = params
         return context
     except Exception as e:
         if f"{self.name}-" in str(e):
             raise not_installed_error(
                 f'"{self.name}" browser was not found.')
         raise e