async def newContext( self, viewport: Union[IntSize, 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: Credentials = None, deviceScaleFactor: int = None, isMobile: bool = None, hasTouch: bool = None, colorScheme: ColorScheme = None, acceptDownloads: bool = None, defaultBrowserType: str = None, ) -> BrowserContext: params = locals_to_params(locals()) # Python is strict in which variables gets passed to methods. We get this # value from the device descriptors, thats why we have to strip it out. if "defaultBrowserType" in params: del params["defaultBrowserType"] if viewport == 0: del params["viewport"] params["noDefaultViewport"] = True if extraHTTPHeaders: params["extraHTTPHeaders"] = serialize_headers(extraHTTPHeaders) channel = await self._channel.send("newContext", params) context = from_channel(channel) self._contexts.append(context) context._browser = self return context
async def setExtraHTTPHeaders(self, headers: Dict) -> None: await self._channel.send( "setExtraHTTPHeaders", dict(headers=serialize_headers(headers)) )