async def launch( self, executablePath: Union[str, Path] = None, channel: BrowserChannel = None, args: List[str] = None, ignoreDefaultArgs: Union[bool, List[str]] = None, handleSIGINT: bool = None, handleSIGTERM: bool = None, handleSIGHUP: bool = None, timeout: float = None, env: Env = None, headless: bool = None, devtools: bool = None, proxy: ProxySettings = None, downloadsPath: Union[str, Path] = None, slowMo: float = None, chromiumSandbox: bool = None, firefoxUserPrefs: Dict[str, Union[str, float, 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 "because executable doesn't exist" in str(e): raise not_installed_error( f'"{self.name}" browser was not found.') raise e
async def launch_persistent_context( self, userDataDir: Union[str, Path], channel: str = None, 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: float = None, env: Env = None, headless: bool = None, devtools: bool = None, proxy: ProxySettings = None, downloadsPath: Union[str, Path] = None, slowMo: float = None, viewport: ViewportSize = None, screen: ViewportSize = None, noViewport: bool = 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: float = None, isMobile: bool = None, hasTouch: bool = None, colorScheme: ColorScheme = None, reducedMotion: ReducedMotion = None, acceptDownloads: bool = None, tracesDir: Union[pathlib.Path, str] = None, chromiumSandbox: bool = None, recordHarPath: Union[Path, str] = None, recordHarOmitContent: bool = None, recordVideoDir: Union[Path, str] = None, recordVideoSize: ViewportSize = None, baseURL: str = None, ) -> BrowserContext: userDataDir = str(Path(userDataDir)) params = locals_to_params(locals()) await normalize_context_params(self._connection._is_sync, params) normalize_launch_params(params) try: context = from_channel(await self._channel.send( "launchPersistentContext", params)) context._options = params return context except Exception as e: if "npx playwright install" in str(e): raise not_installed_error( f'"{self.name}" browser was not found.') raise e