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

Method new_context

playwright/_impl/_fetch.py:70–103  ·  view source on GitHub ↗
(
        self,
        baseURL: str = None,
        extraHTTPHeaders: Dict[str, str] = None,
        httpCredentials: HttpCredentials = None,
        ignoreHTTPSErrors: bool = None,
        proxy: ProxySettings = None,
        userAgent: str = None,
        timeout: float = None,
        storageState: Union[StorageState, str, Path] = None,
        clientCertificates: List[ClientCertificate] = None,
        failOnStatusCode: bool = None,
        maxRedirects: int = None,
    )

Source from the content-addressed store, hash-verified

68 self._dispatcher_fiber = playwright._connection._dispatcher_fiber
69
70 async def new_context(
71 self,
72 baseURL: str = None,
73 extraHTTPHeaders: Dict[str, str] = None,
74 httpCredentials: HttpCredentials = None,
75 ignoreHTTPSErrors: bool = None,
76 proxy: ProxySettings = None,
77 userAgent: str = None,
78 timeout: float = None,
79 storageState: Union[StorageState, str, Path] = None,
80 clientCertificates: List[ClientCertificate] = None,
81 failOnStatusCode: bool = None,
82 maxRedirects: int = None,
83 ) -> "APIRequestContext":
84 params = locals_to_params(locals())
85 if "storageState" in params:
86 storage_state = params["storageState"]
87 if not isinstance(storage_state, dict) and storage_state:
88 params["storageState"] = json.loads(
89 (await async_readfile(storage_state)).decode()
90 )
91 if "extraHTTPHeaders" in params:
92 params["extraHTTPHeaders"] = serialize_headers(params["extraHTTPHeaders"])
93 params["clientCertificates"] = await to_client_certificates_protocol(
94 params.get("clientCertificates")
95 )
96 context = cast(
97 APIRequestContext,
98 from_channel(
99 await self.playwright._channel.send("newRequest", None, params)
100 ),
101 )
102 context._timeout_settings.set_default_timeout(timeout)
103 return context
104
105
106class APIRequestContext(ChannelOwner):

Callers

nothing calls this directly

Calls 8

locals_to_paramsFunction · 0.90
async_readfileFunction · 0.90
serialize_headersFunction · 0.90
from_channelFunction · 0.90
getMethod · 0.45
sendMethod · 0.45
set_default_timeoutMethod · 0.45

Tested by

no test coverage detected