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

Method new_context

playwright/_impl/_browser.py:131–183  ·  view source on GitHub ↗
(
        self,
        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: Sequence[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,
        forcedColors: ForcedColors = None,
        contrast: Contrast = None,
        acceptDownloads: bool = None,
        defaultBrowserType: str = None,
        proxy: ProxySettings = None,
        recordHarPath: Union[Path, str] = None,
        recordHarOmitContent: bool = None,
        recordVideoDir: Union[Path, str] = None,
        recordVideoSize: ViewportSize = None,
        storageState: Union[StorageState, str, Path] = None,
        baseURL: str = None,
        strictSelectors: bool = None,
        serviceWorkers: ServiceWorkersPolicy = None,
        recordHarUrlFilter: Union[Pattern[str], str] = None,
        recordHarMode: HarMode = None,
        recordHarContent: HarContentPolicy = None,
        clientCertificates: List[ClientCertificate] = None,
    )

Source from the content-addressed store, hash-verified

129 return self._is_connected
130
131 async def new_context(
132 self,
133 viewport: ViewportSize = None,
134 screen: ViewportSize = None,
135 noViewport: bool = None,
136 ignoreHTTPSErrors: bool = None,
137 javaScriptEnabled: bool = None,
138 bypassCSP: bool = None,
139 userAgent: str = None,
140 locale: str = None,
141 timezoneId: str = None,
142 geolocation: Geolocation = None,
143 permissions: Sequence[str] = None,
144 extraHTTPHeaders: Dict[str, str] = None,
145 offline: bool = None,
146 httpCredentials: HttpCredentials = None,
147 deviceScaleFactor: float = None,
148 isMobile: bool = None,
149 hasTouch: bool = None,
150 colorScheme: ColorScheme = None,
151 reducedMotion: ReducedMotion = None,
152 forcedColors: ForcedColors = None,
153 contrast: Contrast = None,
154 acceptDownloads: bool = None,
155 defaultBrowserType: str = None,
156 proxy: ProxySettings = None,
157 recordHarPath: Union[Path, str] = None,
158 recordHarOmitContent: bool = None,
159 recordVideoDir: Union[Path, str] = None,
160 recordVideoSize: ViewportSize = None,
161 storageState: Union[StorageState, str, Path] = None,
162 baseURL: str = None,
163 strictSelectors: bool = None,
164 serviceWorkers: ServiceWorkersPolicy = None,
165 recordHarUrlFilter: Union[Pattern[str], str] = None,
166 recordHarMode: HarMode = None,
167 recordHarContent: HarContentPolicy = None,
168 clientCertificates: List[ClientCertificate] = None,
169 ) -> BrowserContext:
170 params = locals_to_params(locals())
171 assert self._browser_type is not None
172 await self._browser_type._prepare_browser_context_params(params)
173
174 channel = await self._channel.send("newContext", None, params)
175 context = cast(BrowserContext, from_channel(channel))
176 await context._initialize_har_from_options(
177 record_har_content=recordHarContent,
178 record_har_mode=recordHarMode,
179 record_har_omit_content=recordHarOmitContent,
180 record_har_path=recordHarPath,
181 record_har_url_filter=recordHarUrlFilter,
182 )
183 return context
184
185 async def new_page(
186 self,

Calls 5

locals_to_paramsFunction · 0.90
from_channelFunction · 0.90
sendMethod · 0.45