Skip to content

Commit

Permalink
feat(roll): roll to 1.50 Playwright (#1654)
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] authored Jan 23, 2025
1 parent 4db51f2 commit 0dba826
Show file tree
Hide file tree
Showing 110 changed files with 2,800 additions and 834 deletions.
13 changes: 11 additions & 2 deletions dotnet/versioned_docs/version-stable/actionability.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,20 @@ Element is considered stable when it has maintained the same bounding box for at

## Enabled

Element is considered enabled unless it is a `<button>`, `<select>`, `<input>` or `<textarea>` with a `disabled` property.
Element is considered enabled when it is **not disabled**.

Element is **disabled** when:
- it is a `<button>`, `<select>`, `<input>`, `<textarea>`, `<option>` or `<optgroup>` with a `[disabled]` attribute;
- it is a `<button>`, `<select>`, `<input>`, `<textarea>`, `<option>` or `<optgroup>` that is a part of a `<fieldset>` with a `[disabled]` attribute;
- it is a descendant of an element with `[aria-disabled=true]` attribute.

## Editable

Element is considered editable when it is [enabled] and does not have `readonly` property set.
Element is considered editable when it is [enabled] and is **not readonly**.

Element is **readonly** when:
- it is a `<select>`, `<input>` or `<textarea>` with a `[readonly]` attribute;
- it has an `[aria-readonly=true]` attribute and an aria role that [supports it](https://w3c.github.io/aria/#aria-readonly).

## Receives Events

Expand Down
2 changes: 1 addition & 1 deletion dotnet/versioned_docs/version-stable/api/class-browser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ In case this browser is connected to, clears all created contexts belonging to t

:::note

This is similar to force quitting the browser. Therefore, you should call [BrowserContext.CloseAsync()](/api/class-browsercontext.mdx#browser-context-close) on any [BrowserContext]'s you explicitly created earlier with [Browser.NewContextAsync()](/api/class-browser.mdx#browser-new-context) **before** calling [Browser.CloseAsync()](/api/class-browser.mdx#browser-close).
This is similar to force-quitting the browser. To close pages gracefully and ensure you receive page close events, call [BrowserContext.CloseAsync()](/api/class-browsercontext.mdx#browser-context-close) on any [BrowserContext] instances you explicitly created earlier using [Browser.NewContextAsync()](/api/class-browser.mdx#browser-new-context) **before** calling [Browser.CloseAsync()](/api/class-browser.mdx#browser-close).
:::

The [Browser] object itself is considered to be disposed and cannot be used anymore.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,15 @@ await BrowserContext.GrantPermissionsAsync(permissions, options);
**Arguments**
- `permissions` [IEnumerable]&lt;[string]&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-grant-permissions-option-permissions"/><a href="#browser-context-grant-permissions-option-permissions" class="list-anchor">#</a>

A permission or an array of permissions to grant. Permissions can be one of the following values:
A list of permissions to grant.

:::danger

Supported permissions differ between browsers, and even between different versions of the same browser. Any permission may stop working after an update.
:::

Here are some permissions that may be supported by some browsers:
* `'accelerometer'`
* `'accessibility-events'`
* `'ambient-light-sensor'`
* `'background-sync'`
* `'camera'`
Expand Down Expand Up @@ -810,7 +816,7 @@ BrowserContext.SetDefaultTimeout(timeout);
**Arguments**
- `timeout` [float]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-set-default-timeout-option-timeout"/><a href="#browser-context-set-default-timeout-option-timeout" class="list-anchor">#</a>

Maximum time in milliseconds
Maximum time in milliseconds. Pass `0` to disable timeout.

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ var browser = await playwright.Chromium.LaunchAsync(new() {

Browser distribution channel.

Use "chromium" to [opt in to new headless mode](../browsers.mdx#opt-in-to-new-headless-mode).
Use "chromium" to [opt in to new headless mode](../browsers.mdx#chromium-new-headless-mode).

Use "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", or "msedge-canary" to use branded [Google Chrome and Microsoft Edge](../browsers.mdx#google-chrome--microsoft-edge).
- `ChromiumSandbox` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-type-launch-option-chromium-sandbox"/><a href="#browser-type-launch-option-chromium-sandbox" class="list-anchor">#</a>
Expand Down Expand Up @@ -289,7 +289,7 @@ await BrowserType.LaunchPersistentContextAsync(userDataDir, options);

Browser distribution channel.

Use "chromium" to [opt in to new headless mode](../browsers.mdx#opt-in-to-new-headless-mode).
Use "chromium" to [opt in to new headless mode](../browsers.mdx#chromium-new-headless-mode).

Use "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", or "msedge-canary" to use branded [Google Chrome and Microsoft Edge](../browsers.mdx#google-chrome--microsoft-edge).
- `ChromiumSandbox` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-chromium-sandbox"/><a href="#browser-type-launch-persistent-context-option-chromium-sandbox" class="list-anchor">#</a>
Expand Down
2 changes: 2 additions & 0 deletions dotnet/versioned_docs/version-stable/api/class-clock.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ await page.Clock.PauseAtAsync(DateTime.Parse("2020-02-02"));
await page.Clock.PauseAtAsync("2020-02-02");
```

For best results, install the clock before navigating the page and set it to a time slightly before the intended test time. This ensures that all timers run normally during page loading, preventing the page from getting stuck. Once the page has fully loaded, you can safely use [Clock.PauseAtAsync()](/api/class-clock.mdx#clock-pause-at) to pause the clock.

**Arguments**
- `time` [Date] | [string]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="clock-pause-at-option-time"/><a href="#clock-pause-at-option-time" class="list-anchor">#</a>

Expand Down
13 changes: 9 additions & 4 deletions dotnet/versioned_docs/version-stable/api/class-locator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var button = page.GetByRole(AriaRole.Button).And(page.GetByTitle("Subscribe"));

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.49</font><x-search>locator.AriaSnapshotAsync</x-search>

Captures the aria snapshot of the given element. Read more about [aria snapshots](../aria-snapshots.mdx) and [Expect(Locator).ToMatchAriaSnapshotAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot) for the corresponding assertion.
Captures the aria snapshot of the given element. Read more about [aria snapshots](../aria-snapshots.mdx) and [Expect(Locator).ToMatchAriaSnapshotAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1) for the corresponding assertion.

**Usage**

Expand Down Expand Up @@ -1492,7 +1492,7 @@ Boolean disabled = await page.GetByRole(AriaRole.Button).IsDisabledAsync();

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.14</font><x-search>locator.IsEditableAsync</x-search>

Returns whether the element is [editable](../actionability.mdx#editable).
Returns whether the element is [editable](../actionability.mdx#editable). If the target element is not an `<input>`, `<textarea>`, `<select>`, `[contenteditable]` and does not have a role allowing `[aria-readonly]`, this method throws an error.

:::warning[Asserting editable state]

Expand Down Expand Up @@ -1692,16 +1692,21 @@ var banana = await page.GetByRole(AriaRole.Listitem).Nth(2);

Creates a locator matching all elements that match one or both of the two locators.

Note that when both locators match something, the resulting locator will have multiple matches and violate [locator strictness](../locators.mdx#strictness) guidelines.
Note that when both locators match something, the resulting locator will have multiple matches, potentially causing a [locator strictness](../locators.mdx#strictness) violation.

**Usage**

Consider a scenario where you'd like to click on a "New email" button, but sometimes a security settings dialog shows up instead. In this case, you can wait for either a "New email" button, or a dialog and act accordingly.

:::note

If both "New email" button and security dialog appear on screen, the "or" locator will match both of them, possibly throwing the ["strict mode violation" error](../locators.mdx#strictness). In this case, you can use [Locator.First](/api/class-locator.mdx#locator-first) to only match one of them.
:::

```csharp
var newEmail = page.GetByRole(AriaRole.Button, new() { Name = "New" });
var dialog = page.GetByText("Confirm security settings");
await Expect(newEmail.Or(dialog)).ToBeVisibleAsync();
await Expect(newEmail.Or(dialog).First).ToBeVisibleAsync();
if (await dialog.IsVisibleAsync())
await page.GetByRole(AriaRole.Button, new() { Name = "Dismiss" }).ClickAsync();
await newEmail.ClickAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ await Expect(locator).ToBeCheckedAsync();
**Arguments**
- `options` `LocatorAssertionsToBeCheckedOptions?` *(optional)*
- `Checked` [bool]? *(optional)* <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-be-checked-option-checked"/><a href="#locator-assertions-to-be-checked-option-checked" class="list-anchor">#</a>

Provides state to assert for. Asserts for input to be checked by default. This option can't be used when [Indeterminate](/api/class-locatorassertions.mdx#locator-assertions-to-be-checked-option-indeterminate) is set to true.
- `Indeterminate` [bool]? *(optional)* <font size="2">Added in: v1.50</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-be-checked-option-indeterminate"/><a href="#locator-assertions-to-be-checked-option-indeterminate" class="list-anchor">#</a>

Asserts that the element is in the indeterminate (mixed) state. Only supported for checkboxes and radio buttons. This option can't be true when [Checked](/api/class-locatorassertions.mdx#locator-assertions-to-be-checked-option-checked) is provided.
- `Timeout` [float]? *(optional)* <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-be-checked-option-timeout"/><a href="#locator-assertions-to-be-checked-option-timeout" class="list-anchor">#</a>

Time to retry the assertion for in milliseconds. Defaults to `5000`.
Expand Down Expand Up @@ -165,7 +170,7 @@ Ensures the [Locator] points to an enabled element.

```csharp
var locator = Page.Locator("button.submit");
await Expect(locator).toBeEnabledAsync();
await Expect(locator).ToBeEnabledAsync();
```

**Arguments**
Expand Down Expand Up @@ -377,7 +382,7 @@ Ensures the [Locator] points to an element with a given [accessible description]

```csharp
var locator = Page.GetByTestId("save-button");
await Expect(locator).toHaveAccessibleDescriptionAsync("Save results to disk");
await Expect(locator).ToHaveAccessibleDescriptionAsync("Save results to disk");
```

**Arguments**
Expand All @@ -397,6 +402,36 @@ await Expect(locator).toHaveAccessibleDescriptionAsync("Save results to disk");

---

### ToHaveAccessibleErrorMessageAsync {#locator-assertions-to-have-accessible-error-message}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.50</font><x-search>locatorAssertions.ToHaveAccessibleErrorMessageAsync</x-search>

Ensures the [Locator] points to an element with a given [aria errormessage](https://w3c.github.io/aria/#aria-errormessage).

**Usage**

```csharp
var locator = Page.GetByTestId("username-input");
await Expect(locator).ToHaveAccessibleErrorMessageAsync("Username is required.");
```

**Arguments**
- `errorMessage` [string] | [Regex]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-accessible-error-message-option-error-message"/><a href="#locator-assertions-to-have-accessible-error-message-option-error-message" class="list-anchor">#</a>

Expected accessible error message.
- `options` `LocatorAssertionsToHaveAccessibleErrorMessageOptions?` *(optional)*
- `IgnoreCase` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-accessible-error-message-option-ignore-case"/><a href="#locator-assertions-to-have-accessible-error-message-option-ignore-case" class="list-anchor">#</a>

Whether to perform case-insensitive match. [IgnoreCase](/api/class-locatorassertions.mdx#locator-assertions-to-have-accessible-error-message-option-ignore-case) option takes precedence over the corresponding regular expression flag if specified.
- `Timeout` [float]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-accessible-error-message-option-timeout"/><a href="#locator-assertions-to-have-accessible-error-message-option-timeout" class="list-anchor">#</a>

Time to retry the assertion for in milliseconds. Defaults to `5000`.

**Returns**
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-accessible-error-message-return"/><a href="#locator-assertions-to-have-accessible-error-message-return" class="list-anchor">#</a>

---

### ToHaveAccessibleNameAsync {#locator-assertions-to-have-accessible-name}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.44</font><x-search>locatorAssertions.ToHaveAccessibleNameAsync</x-search>
Expand All @@ -407,7 +442,7 @@ Ensures the [Locator] points to an element with a given [accessible name](https:

```csharp
var locator = Page.GetByTestId("save-button");
await Expect(locator).toHaveAccessibleNameAsync("Save to disk");
await Expect(locator).ToHaveAccessibleNameAsync("Save to disk");
```

**Arguments**
Expand Down Expand Up @@ -464,21 +499,21 @@ await Expect(locator).ToHaveAttributeAsync("type", "text");

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.20</font><x-search>locatorAssertions.ToHaveClassAsync</x-search>

Ensures the [Locator] points to an element with given CSS classes. This needs to be a full match or using a relaxed regular expression.
Ensures the [Locator] points to an element with given CSS classes. When a string is provided, it must fully match the element's `class` attribute. To match individual classes or perform partial matches, use a regular expression:

**Usage**

```html
<div class='selected row' id='component'></div>
<div class='middle selected row' id='component'></div>
```

```csharp
var locator = Page.Locator("#component");
await Expect(locator).ToHaveClassAsync(new Regex("selected"));
await Expect(locator).ToHaveClassAsync("selected row");
await Expect(locator).ToHaveClassAsync(new Regex("(^|\\s)selected(\\s|$)"));
await Expect(locator).ToHaveClassAsync("middle selected row");
```

Note that if array is passed as an expected value, entire lists of elements can be asserted:
When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected class values. Each element's class attribute is matched against the corresponding string or regular expression in the array:

```csharp
var locator = Page.Locator("list > .component");
Expand Down Expand Up @@ -776,7 +811,7 @@ await Expect(locator).ToHaveValuesAsync(new Regex[] { new Regex("R"), new Regex(

---

### ToMatchAriaSnapshotAsync {#locator-assertions-to-match-aria-snapshot}
### ToMatchAriaSnapshotAsync {#locator-assertions-to-match-aria-snapshot-1}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.49</font><x-search>locatorAssertions.ToMatchAriaSnapshotAsync</x-search>

Expand All @@ -793,14 +828,14 @@ await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(@"
```

**Arguments**
- `expected` [string]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-option-expected"/><a href="#locator-assertions-to-match-aria-snapshot-option-expected" class="list-anchor">#</a>
- `expected` [string]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-1-option-expected"/><a href="#locator-assertions-to-match-aria-snapshot-1-option-expected" class="list-anchor">#</a>
- `options` `LocatorAssertionsToMatchAriaSnapshotOptions?` *(optional)*
- `Timeout` [float]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-option-timeout"/><a href="#locator-assertions-to-match-aria-snapshot-option-timeout" class="list-anchor">#</a>
- `Timeout` [float]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-1-option-timeout"/><a href="#locator-assertions-to-match-aria-snapshot-1-option-timeout" class="list-anchor">#</a>

Time to retry the assertion for in milliseconds. Defaults to `5000`.

**Returns**
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-return"/><a href="#locator-assertions-to-match-aria-snapshot-return" class="list-anchor">#</a>
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-1-return"/><a href="#locator-assertions-to-match-aria-snapshot-1-return" class="list-anchor">#</a>

---

Expand Down
7 changes: 1 addition & 6 deletions dotnet/versioned_docs/version-stable/api/class-page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1339,11 +1339,6 @@ await Page.PauseAsync();

Returns the PDF buffer.

:::note

Generating a pdf is currently only supported in Chromium headless.
:::

`page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call [Page.EmulateMediaAsync()](/api/class-page.mdx#page-emulate-media) before calling `page.pdf()`:

:::note
Expand Down Expand Up @@ -2389,7 +2384,7 @@ Page.SetDefaultTimeout(timeout);
**Arguments**
- `timeout` [float]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="page-set-default-timeout-option-timeout"/><a href="#page-set-default-timeout-option-timeout" class="list-anchor">#</a>

Maximum time in milliseconds
Maximum time in milliseconds. Pass `0` to disable timeout.

---

Expand Down
Loading

0 comments on commit 0dba826

Please sign in to comment.