Skip to content

Commit

Permalink
feat(roll): roll to ToT Playwright (15-06-22) (microsoft#592)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
playwrightmachine and github-actions[bot] committed Jun 16, 2022
1 parent 26dd38b commit 917ce0e
Show file tree
Hide file tree
Showing 32 changed files with 599 additions and 122 deletions.
14 changes: 6 additions & 8 deletions dotnet/docs/api/class-browser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@ Indicates that the browser is connected.
- `ScreenSize`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-context-option-screen"/> &#60;ScreenSize?&#62; Emulates consistent window screen size available inside web page via `window.screen`. Is only used when the `viewport` is set.<a href="#browser-new-context-option-screen" class="list-anchor">#</a>
- `Width` &#60;[int]&#62; page width in pixels.
- `Height` &#60;[int]&#62; page height in pixels.
- `ServiceWorkers`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-context-option-service-workers"/> &#60;`enum ServiceWorkerPolicy { Allow, Block }?`&#62; `"allow"`: [Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) can be registered by sites.<a href="#browser-new-context-option-service-workers" class="list-anchor">#</a>
* `"block"`: Playwright will block all registration of Service Workers.

Defaults to `"allow"`.
- `ServiceWorkers`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-context-option-service-workers"/> &#60;`enum ServiceWorkerPolicy { Allow, Block }?`&#62; Whether to allow sites to register Service workers. Defaults to `'allow'`.<a href="#browser-new-context-option-service-workers" class="list-anchor">#</a>
* `'allow'`: [Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) can be registered.
* `'block'`: Playwright will block all registration of Service Workers.
- `StorageState`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-context-option-storage-state"/> &#60;[string]?&#62; Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [BrowserContext.StorageStateAsync(options)](./api/class-browsercontext.mdx#browser-context-storage-state).<a href="#browser-new-context-option-storage-state" class="list-anchor">#</a>
- `StorageStatePath`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-context-option-storage-state-path"/> &#60;[string]?&#62; Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [BrowserContext.StorageStateAsync(options)](./api/class-browsercontext.mdx#browser-context-storage-state). Path to the file with saved storage state.<a href="#browser-new-context-option-storage-state-path" class="list-anchor">#</a>
- `StrictSelectors`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-context-option-strict-selectors"/> &#60;[bool]?&#62; If specified, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors that imply single target DOM element will throw when more than one element matches the selector. See [Locator] to learn more about the strict mode.<a href="#browser-new-context-option-strict-selectors" class="list-anchor">#</a>
Expand Down Expand Up @@ -201,10 +200,9 @@ await page.GotoAsync("https://www.bing.com");
- `ScreenSize`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-page-option-screen"/> &#60;ScreenSize?&#62; Emulates consistent window screen size available inside web page via `window.screen`. Is only used when the `viewport` is set.<a href="#browser-new-page-option-screen" class="list-anchor">#</a>
- `Width` &#60;[int]&#62; page width in pixels.
- `Height` &#60;[int]&#62; page height in pixels.
- `ServiceWorkers`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-page-option-service-workers"/> &#60;`enum ServiceWorkerPolicy { Allow, Block }?`&#62; `"allow"`: [Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) can be registered by sites.<a href="#browser-new-page-option-service-workers" class="list-anchor">#</a>
* `"block"`: Playwright will block all registration of Service Workers.

Defaults to `"allow"`.
- `ServiceWorkers`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-page-option-service-workers"/> &#60;`enum ServiceWorkerPolicy { Allow, Block }?`&#62; Whether to allow sites to register Service workers. Defaults to `'allow'`.<a href="#browser-new-page-option-service-workers" class="list-anchor">#</a>
* `'allow'`: [Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) can be registered.
* `'block'`: Playwright will block all registration of Service Workers.
- `StorageState`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-page-option-storage-state"/> &#60;[string]?&#62; Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [BrowserContext.StorageStateAsync(options)](./api/class-browsercontext.mdx#browser-context-storage-state).<a href="#browser-new-page-option-storage-state" class="list-anchor">#</a>
- `StorageStatePath`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-page-option-storage-state-path"/> &#60;[string]?&#62; Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [BrowserContext.StorageStateAsync(options)](./api/class-browsercontext.mdx#browser-context-storage-state). Path to the file with saved storage state.<a href="#browser-new-page-option-storage-state-path" class="list-anchor">#</a>
- `StrictSelectors`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-page-option-strict-selectors"/> &#60;[bool]?&#62; If specified, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors that imply single target DOM element will throw when more than one element matches the selector. See [Locator] to learn more about the strict mode.<a href="#browser-new-page-option-strict-selectors" class="list-anchor">#</a>
Expand Down
21 changes: 21 additions & 0 deletions dotnet/docs/api/class-browsercontext.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ await context.CloseAsync();
- [BrowserContext.NewPageAsync()](./api/class-browsercontext.mdx#browser-context-new-page)
- [BrowserContext.Pages](./api/class-browsercontext.mdx#browser-context-pages)
- [BrowserContext.RouteAsync(url, handler, options)](./api/class-browsercontext.mdx#browser-context-route)
- [BrowserContext.RouteFromHarAsync(harPath, options)](./api/class-browsercontext.mdx#browser-context-route-from-har)
- [BrowserContext.RunAndWaitForPageAsync(action, options)](./api/class-browsercontext.mdx#browser-context-wait-for-page)
- [BrowserContext.SetDefaultNavigationTimeout(timeout)](./api/class-browsercontext.mdx#browser-context-set-default-navigation-timeout)
- [BrowserContext.SetDefaultTimeout(timeout)](./api/class-browsercontext.mdx#browser-context-set-default-timeout)
Expand All @@ -53,6 +54,7 @@ await context.CloseAsync();
- [BrowserContext.SetOfflineAsync(offline)](./api/class-browsercontext.mdx#browser-context-set-offline)
- [BrowserContext.StorageStateAsync(options)](./api/class-browsercontext.mdx#browser-context-storage-state)
- [BrowserContext.UnrouteAsync(url, handler)](./api/class-browsercontext.mdx#browser-context-unroute)
- [BrowserContext.UnrouteFromHarAsync(harPath)](./api/class-browsercontext.mdx#browser-context-unroute-from-har)
- [BrowserContext.WaitForPageAsync(action, options)](./api/class-browsercontext.mdx#browser-context-wait-for-page)
- [BrowserContext.APIRequest](./api/class-browsercontext.mdx#browser-context-request)
- [BrowserContext.Tracing](./api/class-browsercontext.mdx#browser-context-tracing)
Expand Down Expand Up @@ -391,6 +393,19 @@ To remove a route with its handler you can use [BrowserContext.UnrouteAsync(url,
Enabling routing disables http cache.
:::

## BrowserContext.RouteFromHarAsync(harPath, options) {#browser-context-route-from-har}
- `harPath`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-context-route-from-har-option-har-path"/> &#60;[string]&#62; Path to the HAR file with prerecorded network data. If HAR file contains an entry with the matching url and HTTP method, then the entry's headers, status and body will be used to fulfill. An entry resulting in a redirect will be followed automatically. If there is no matching entry in the file the execution continues to try other configured HAR files and [Route] handlers. If `path` is a relative path, then it is resolved relative to the current working directory.<a href="#browser-context-route-from-har-option-har-path" class="list-anchor">#</a>
- `options` &#60;`BrowserContextRouteFromHarOptions?`&#62;
- `Strict`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-context-route-from-har-option-strict"/> &#60;[bool]?&#62; If set to true any request not found in the HAR file will be aborted. If set to false missing requests will continue normal flow and can be handled by other [Route] handlers or served from other HAR files configured with [BrowserContext.RouteFromHarAsync(harPath, options)](./api/class-browsercontext.mdx#browser-context-route-from-har). Defaults to true.<a href="#browser-context-route-from-har-option-strict" class="list-anchor">#</a>
- `Url`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-context-route-from-har-option-url"/> &#60;[string]?|[Regex]?&#62; A glob pattern or regular expression to match request URL while routing. Only requests with URL matching the pattern will be surved from the HAR file. If not specified, all requests are served from the HAR file.<a href="#browser-context-route-from-har-option-url" class="list-anchor">#</a>
- returns:<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-context-route-from-har-return"/> &#60;[void]&#62;<a href="#browser-context-route-from-har-return" class="list-anchor">#</a>

Provides the capability to serve network requests that are made in the context from prerecorded HAR file.

:::note
[BrowserContext.RouteFromHarAsync(harPath, options)](./api/class-browsercontext.mdx#browser-context-route-from-har) will not intercept requests intercepted by Service Worker. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);`
:::

## BrowserContext.RunAndWaitForPageAsync(action, options) {#browser-context-wait-for-page}
- `options` &#60;`BrowserContextRunAndWaitForPageOptions?`&#62;
- `Predicate`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-context-wait-for-page-option-predicate"/> &#60;[Func]<[Page]?, bool>&#62; Receives the [Page] object and resolves to truthy value when the waiting should resolve.<a href="#browser-context-wait-for-page-option-predicate" class="list-anchor">#</a>
Expand Down Expand Up @@ -481,6 +496,12 @@ Returns storage state for this browser context, contains current cookies and loc

Removes a route created with [BrowserContext.RouteAsync(url, handler, options)](./api/class-browsercontext.mdx#browser-context-route). When `handler` is not specified, removes all routes for the `url`.

## BrowserContext.UnrouteFromHarAsync(harPath) {#browser-context-unroute-from-har}
- `harPath`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-context-unroute-from-har-option-har-path"/> &#60;[string]&#62; Path to the HAR file which was passed to [BrowserContext.RouteFromHarAsync(harPath, options)](./api/class-browsercontext.mdx#browser-context-route-from-har).<a href="#browser-context-unroute-from-har-option-har-path" class="list-anchor">#</a>
- returns:<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-context-unroute-from-har-return"/> &#60;[void]&#62;<a href="#browser-context-unroute-from-har-return" class="list-anchor">#</a>

Removes HAR handler previously added with [BrowserContext.RouteFromHarAsync(harPath, options)](./api/class-browsercontext.mdx#browser-context-route-from-har).

## BrowserContext.APIRequest {#browser-context-request}
- type: &#60;[APIRequestContext]&#62;

Expand Down
7 changes: 3 additions & 4 deletions dotnet/docs/api/class-browsertype.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,9 @@ var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
- `ScreenSize`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-screen"/> &#60;ScreenSize?&#62; Emulates consistent window screen size available inside web page via `window.screen`. Is only used when the `viewport` is set.<a href="#browser-type-launch-persistent-context-option-screen" class="list-anchor">#</a>
- `Width` &#60;[int]&#62; page width in pixels.
- `Height` &#60;[int]&#62; page height in pixels.
- `ServiceWorkers`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-service-workers"/> &#60;`enum ServiceWorkerPolicy { Allow, Block }?`&#62; `"allow"`: [Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) can be registered by sites.<a href="#browser-type-launch-persistent-context-option-service-workers" class="list-anchor">#</a>
* `"block"`: Playwright will block all registration of Service Workers.

Defaults to `"allow"`.
- `ServiceWorkers`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-service-workers"/> &#60;`enum ServiceWorkerPolicy { Allow, Block }?`&#62; Whether to allow sites to register Service workers. Defaults to `'allow'`.<a href="#browser-type-launch-persistent-context-option-service-workers" class="list-anchor">#</a>
* `'allow'`: [Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) can be registered.
* `'block'`: Playwright will block all registration of Service Workers.
- `SlowMo`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-slow-mo"/> &#60;[double]?&#62; Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.<a href="#browser-type-launch-persistent-context-option-slow-mo" class="list-anchor">#</a>
- `StrictSelectors`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-strict-selectors"/> &#60;[bool]?&#62; If specified, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors that imply single target DOM element will throw when more than one element matches the selector. See [Locator] to learn more about the strict mode.<a href="#browser-type-launch-persistent-context-option-strict-selectors" class="list-anchor">#</a>
- `Timeout`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-timeout"/> &#60;[double]?&#62; Maximum time in milliseconds to wait for the browser instance to start. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.<a href="#browser-type-launch-persistent-context-option-timeout" class="list-anchor">#</a>
Expand Down

0 comments on commit 917ce0e

Please sign in to comment.