예제 #1
0
 async def launchServer(
     self,
     executablePath: str = None,
     args: List[str] = None,
     ignoreDefaultArgs: List[str] = None,
     handleSIGINT: bool = None,
     handleSIGTERM: bool = None,
     handleSIGHUP: bool = None,
     timeout: int = None,
     env: Dict = None,
     headless: bool = None,
     devtools: bool = None,
     proxy: Dict = None,
     downloadsPath: str = None,
     port: int = None,
     chromiumSandbox: bool = None,
 ) -> Browser:
     try:
         return from_channel(
             await self._channel.send("launchServer", locals_to_params(locals()))
         )
     except Exception as e:
         if f"{self.name}-" in str(e):
             raise not_installed_error(f'"{self.name}" browser was not found.')
         raise e
예제 #2
0
 async def launch(
     self,
     executablePath: str = 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: ProxyServer = None,
     downloadsPath: str = None,
     slowMo: int = None,
     chromiumSandbox: 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
예제 #3
0
async def run_driver_async() -> Connection:
    package_path = os.path.dirname(os.path.abspath(__file__))
    driver_name = compute_driver_name()
    driver_executable = os.path.join(package_path, driver_name)
    archive_name = os.path.join(package_path, "drivers", driver_name + ".gz")

    if not os.path.exists(driver_executable) or os.path.getmtime(
        driver_executable
    ) < os.path.getmtime(archive_name):
        raise not_installed_error(
            "Playwright requires additional post-installation step to be made."
        )

    proc = await asyncio.create_subprocess_exec(
        driver_executable,
        stdin=asyncio.subprocess.PIPE,
        stdout=asyncio.subprocess.PIPE,
        stderr=asyncio.subprocess.PIPE,
        limit=32768,
    )
    assert proc.stdout
    assert proc.stdin
    connection = Connection(
        proc.stdout, proc.stdin, create_remote_object, asyncio.get_event_loop()
    )
    return connection
예제 #4
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: ProxyServer = None,
     downloadsPath: Union[str, Path] = None,
     slowMo: int = None,
     viewport: IntSize = 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: Credentials = None,
     deviceScaleFactor: int = None,
     isMobile: bool = None,
     hasTouch: bool = None,
     colorScheme: ColorScheme = None,
     acceptDownloads: bool = None,
     chromiumSandbox: bool = None,
     videosPath: str = None,
     videoSize: IntSize = None,
     recordHar: RecordHarOptions = None,
 ) -> BrowserContext:
     userDataDir = str(Path(userDataDir))
     params = locals_to_params(locals())
     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
예제 #5
0
 async def launchPersistentContext(
     self,
     userDataDir: str,
     executablePath: str = None,
     args: List[str] = None,
     ignoreDefaultArgs: List[str] = None,
     handleSIGINT: bool = None,
     handleSIGTERM: bool = None,
     handleSIGHUP: bool = None,
     timeout: int = None,
     env: Dict = None,
     headless: bool = None,
     devtools: bool = None,
     proxy: Dict = None,
     downloadsPath: str = None,
     slowMo: int = None,
     viewport: Dict = None,
     ignoreHTTPSErrors: bool = None,
     javaScriptEnabled: bool = None,
     bypassCSP: bool = None,
     userAgent: str = None,
     locale: str = None,
     timezoneId: str = None,
     geolocation: Dict = None,
     permissions: List[str] = None,
     extraHTTPHeaders: Dict[str, str] = None,
     offline: bool = None,
     httpCredentials: Dict = None,
     deviceScaleFactor: int = None,
     isMobile: bool = None,
     hasTouch: bool = None,
     colorScheme: ColorScheme = None,
     acceptDownloads: bool = None,
 ) -> BrowserContext:
     try:
         return from_channel(
             await self._channel.send(
                 "launchPersistentContext", locals_to_params(locals())
             )
         )
     except Exception as e:
         if f"{self.name}-" in str(e):
             raise not_installed_error(f'"{self.name}" browser was not found.')
         raise e