Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dotnet/docs/actionability.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Playwright includes auto-retrying assertions that remove flakiness by waiting un
| [Expect(Locator).ToHaveAttributeAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-attribute) | Element has a DOM attribute |
| [Expect(Locator).ToHaveClassAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-class) | Element has a class property |
| [Expect(Locator).ToHaveCountAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-count) | List has exact number of children |
| [Expect(Locator).ToHaveCSSAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css-1) | Element has CSS property |
| [Expect(Locator).ToHaveCSSAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css) | Element has CSS property |
| [Expect(Locator).ToHaveIdAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-id) | Element has an ID |
| [Expect(Locator).ToHaveJSPropertyAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-js-property) | Element has a JavaScript property |
| [Expect(Locator).ToHaveTextAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) | Element matches text |
Expand Down
12 changes: 6 additions & 6 deletions dotnet/docs/api/class-locatorassertions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ Let's see how we can use the assertion:

```csharp
// ✓ Contains the right items in the right order
await Expect(Page.Locator("ul > li")).ToContainTextAsync(new string[] {"Text 1", "Text 3", "Text 4"});
await Expect(Page.Locator("ul > li")).ToContainTextAsync(new string[] {"Text 1", "Text 3"});

// ✖ Wrong order
await Expect(Page.Locator("ul > li")).ToContainTextAsync(new string[] {"Text 3", "Text 2"});
Expand Down Expand Up @@ -609,7 +609,7 @@ await Expect(locator).ToHaveCountAsync(3);

---

### ToHaveCSSAsync {#locator-assertions-to-have-css-1}
### ToHaveCSSAsync {#locator-assertions-to-have-css}

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

Expand All @@ -623,19 +623,19 @@ await Expect(locator).ToHaveCSSAsync("display", "flex");
```

**Arguments**
- `name` [string] <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-1-option-name"/><a href="#locator-assertions-to-have-css-1-option-name" class="list-anchor">#</a>
- `name` [string] <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-option-name"/><a href="#locator-assertions-to-have-css-option-name" class="list-anchor">#</a>

CSS property name.
- `value` [string] | [Regex] <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-1-option-value"/><a href="#locator-assertions-to-have-css-1-option-value" class="list-anchor">#</a>
- `value` [string] | [Regex] <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-option-value"/><a href="#locator-assertions-to-have-css-option-value" class="list-anchor">#</a>

CSS property value.
- `options` `LocatorAssertionsToHaveCSSOptions?` *(optional)*
- `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-have-css-1-option-timeout"/><a href="#locator-assertions-to-have-css-1-option-timeout" class="list-anchor">#</a>
- `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-have-css-option-timeout"/><a href="#locator-assertions-to-have-css-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-css-1-return"/><a href="#locator-assertions-to-have-css-1-return" class="list-anchor">#</a>
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-return"/><a href="#locator-assertions-to-have-css-return" class="list-anchor">#</a>

---

Expand Down
2 changes: 1 addition & 1 deletion dotnet/docs/test-assertions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import HTMLCard from '@site/src/components/HTMLCard';
| [Expect(Locator).ToHaveAttributeAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-attribute) | Element has a DOM attribute |
| [Expect(Locator).ToHaveClassAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-class) | Element has a class property |
| [Expect(Locator).ToHaveCountAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-count) | List has exact number of children |
| [Expect(Locator).ToHaveCSSAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css-1) | Element has CSS property |
| [Expect(Locator).ToHaveCSSAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css) | Element has CSS property |
| [Expect(Locator).ToHaveIdAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-id) | Element has an ID |
| [Expect(Locator).ToHaveJSPropertyAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-js-property) | Element has a JavaScript property |
| [Expect(Locator).ToHaveRoleAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-role) | Element has a specific [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles) |
Expand Down
2 changes: 1 addition & 1 deletion java/docs/actionability.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Playwright includes auto-retrying assertions that remove flakiness by waiting un
| [assertThat(locator).hasAttribute()](/api/class-locatorassertions.mdx#locator-assertions-to-have-attribute) | Element has a DOM attribute |
| [assertThat(locator).hasClass()](/api/class-locatorassertions.mdx#locator-assertions-to-have-class) | Element has a class property |
| [assertThat(locator).hasCount()](/api/class-locatorassertions.mdx#locator-assertions-to-have-count) | List has exact number of children |
| [assertThat(locator).hasCSS()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css-1) | Element has CSS property |
| [assertThat(locator).hasCSS()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css) | Element has CSS property |
| [assertThat(locator).hasId()](/api/class-locatorassertions.mdx#locator-assertions-to-have-id) | Element has an ID |
| [assertThat(locator).hasJSProperty()](/api/class-locatorassertions.mdx#locator-assertions-to-have-js-property) | Element has a JavaScript property |
| [assertThat(locator).hasText()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) | Element matches text |
Expand Down
12 changes: 6 additions & 6 deletions java/docs/api/class-locatorassertions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Let's see how we can use the assertion:

```java
// ✓ Contains the right items in the right order
assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});

// ✖ Wrong order
assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
Expand Down Expand Up @@ -328,7 +328,7 @@ assertThat(page.locator("list > .component")).hasCount(3);

---

### hasCSS {#locator-assertions-to-have-css-1}
### hasCSS {#locator-assertions-to-have-css}

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

Expand All @@ -341,19 +341,19 @@ assertThat(page.getByRole(AriaRole.BUTTON)).hasCSS("display", "flex");
```

**Arguments**
- `name` [String] <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-1-option-name"/><a href="#locator-assertions-to-have-css-1-option-name" class="list-anchor">#</a>
- `name` [String] <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-option-name"/><a href="#locator-assertions-to-have-css-option-name" class="list-anchor">#</a>

CSS property name.
- `value` [String] | [Pattern] <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-1-option-value"/><a href="#locator-assertions-to-have-css-1-option-value" class="list-anchor">#</a>
- `value` [String] | [Pattern] <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-option-value"/><a href="#locator-assertions-to-have-css-option-value" class="list-anchor">#</a>

CSS property value.
- `options` `LocatorAssertions.HasCSSOptions` *(optional)*
- `setTimeout` [double] *(optional)* <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-1-option-timeout"/><a href="#locator-assertions-to-have-css-1-option-timeout" class="list-anchor">#</a>
- `setTimeout` [double] *(optional)* <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-option-timeout"/><a href="#locator-assertions-to-have-css-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-css-1-return"/><a href="#locator-assertions-to-have-css-1-return" class="list-anchor">#</a>
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-return"/><a href="#locator-assertions-to-have-css-return" class="list-anchor">#</a>

---

Expand Down
2 changes: 1 addition & 1 deletion java/docs/test-assertions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import HTMLCard from '@site/src/components/HTMLCard';
| [assertThat(locator).hasAttribute()](/api/class-locatorassertions.mdx#locator-assertions-to-have-attribute) | Element has a DOM attribute |
| [assertThat(locator).hasClass()](/api/class-locatorassertions.mdx#locator-assertions-to-have-class) | Element has a class property |
| [assertThat(locator).hasCount()](/api/class-locatorassertions.mdx#locator-assertions-to-have-count) | List has exact number of children |
| [assertThat(locator).hasCSS()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css-1) | Element has CSS property |
| [assertThat(locator).hasCSS()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css) | Element has CSS property |
| [assertThat(locator).hasId()](/api/class-locatorassertions.mdx#locator-assertions-to-have-id) | Element has an ID |
| [assertThat(locator).hasJSProperty()](/api/class-locatorassertions.mdx#locator-assertions-to-have-js-property) | Element has a JavaScript property |
| [assertThat(locator).hasRole()](/api/class-locatorassertions.mdx#locator-assertions-to-have-role) | Element has a specific [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles) |
Expand Down
2 changes: 1 addition & 1 deletion nodejs/docs/actionability.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Playwright includes auto-retrying assertions that remove flakiness by waiting un
| [expect(locator).toHaveAttribute()](/api/class-locatorassertions.mdx#locator-assertions-to-have-attribute) | Element has a DOM attribute |
| [expect(locator).toHaveClass()](/api/class-locatorassertions.mdx#locator-assertions-to-have-class) | Element has a class property |
| [expect(locator).toHaveCount()](/api/class-locatorassertions.mdx#locator-assertions-to-have-count) | List has exact number of children |
| [expect(locator).toHaveCSS()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css-1) | Element has CSS property |
| [expect(locator).toHaveCSS()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css) | Element has CSS property |
| [expect(locator).toHaveId()](/api/class-locatorassertions.mdx#locator-assertions-to-have-id) | Element has an ID |
| [expect(locator).toHaveJSProperty()](/api/class-locatorassertions.mdx#locator-assertions-to-have-js-property) | Element has a JavaScript property |
| [expect(locator).toHaveText()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) | Element matches text |
Expand Down
47 changes: 6 additions & 41 deletions nodejs/docs/api/class-locatorassertions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,9 @@ await expect(list).toHaveCount(3);

---

### toHaveCSS(name, value) {#locator-assertions-to-have-css-1}
### toHaveCSS {#locator-assertions-to-have-css}

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

Ensures the [Locator] resolves to an element with the given computed CSS style.

Expand All @@ -648,54 +648,19 @@ await expect(locator).toHaveCSS('display', 'flex');
```

**Arguments**
- `name` [string] <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-1-option-name"/><a href="#locator-assertions-to-have-css-1-option-name" class="list-anchor">#</a>
- `name` [string] <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-option-name"/><a href="#locator-assertions-to-have-css-option-name" class="list-anchor">#</a>

CSS property name.
- `value` [string] | [RegExp] <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-1-option-value"/><a href="#locator-assertions-to-have-css-1-option-value" class="list-anchor">#</a>
- `value` [string] | [RegExp] <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-option-value"/><a href="#locator-assertions-to-have-css-option-value" class="list-anchor">#</a>

CSS property value.
- `options` [Object] *(optional)*
- `timeout` [number] *(optional)* <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-1-option-timeout"/><a href="#locator-assertions-to-have-css-1-option-timeout" class="list-anchor">#</a>
- `timeout` [number] *(optional)* <font size="2">Added in: v1.18</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-option-timeout"/><a href="#locator-assertions-to-have-css-option-timeout" class="list-anchor">#</a>

Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.

**Returns**
- [Promise]&lt;[void]&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-1-return"/><a href="#locator-assertions-to-have-css-1-return" class="list-anchor">#</a>

---

### toHaveCSS(styles) {#locator-assertions-to-have-css-2}

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

Ensures the [Locator] resolves to an element with the given computed CSS properties.

:::note

The `CSSProperties` object parameter for toHaveCSS requires `react` to be installed for type checking.
:::

**Usage**

```js
const locator = page.getByRole('button');
await expect(locator).toHaveCSS({
display: 'flex',
backgroundColor: 'rgb(255, 0, 0)'
});
```

**Arguments**
- `styles` [CSSProperties]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-2-option-styles"/><a href="#locator-assertions-to-have-css-2-option-styles" class="list-anchor">#</a>

CSS properties object.
- `options` [Object] *(optional)*
- `timeout` [number] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-2-option-timeout"/><a href="#locator-assertions-to-have-css-2-option-timeout" class="list-anchor">#</a>

Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.

**Returns**
- [Promise]&lt;[void]&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-2-return"/><a href="#locator-assertions-to-have-css-2-return" class="list-anchor">#</a>
- [Promise]&lt;[void]&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-have-css-return"/><a href="#locator-assertions-to-have-css-return" class="list-anchor">#</a>

---

Expand Down
4 changes: 4 additions & 0 deletions nodejs/docs/api/class-page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ await page.agent(options);
- `cacheOutFile` [string] *(optional)*

When specified, generated entries are written into the `cacheOutFile` instead of updating the `cacheFile`.
- `expect` [Object] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="page-agent-option-expect"/><a href="#page-agent-option-expect" class="list-anchor">#</a>
- `timeout` [number] *(optional)*

Default timeout for expect calls in milliseconds, defaults to 5000ms.
- `limits` [Object] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="page-agent-option-limits"/><a href="#page-agent-option-limits" class="list-anchor">#</a>
- `maxTokens` [number] *(optional)*

Expand Down
6 changes: 3 additions & 3 deletions nodejs/docs/api/class-pageagent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ await agent.expect('"0 items" to be reported');
Maximum number of tokens to consume. The agentic loop will stop after input + output tokens exceed this value. Defaults to context-wide value specified in `agent` property.
- `timeout` [number] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="page-agent-expect-option-timeout"/><a href="#page-agent-expect-option-timeout" class="list-anchor">#</a>

Request timeout in milliseconds. Defaults to action timeout. Pass `0` to disable timeout.
Expect timeout in milliseconds. Defaults to `5000`. The default value can be changed via `expect.timeout` option in the config, or by specifying the `expect` property of the [expect](/api/class-page.mdx#page-agent-option-expect) option. Pass `0` to disable timeout.

**Returns**
- [Promise]&lt;[void]&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="page-agent-expect-return"/><a href="#page-agent-expect-return" class="list-anchor">#</a>
Expand Down Expand Up @@ -102,7 +102,7 @@ await agent.extract('List of items in the cart', z.object({
Maximum number of tokens to consume. The agentic loop will stop after input + output tokens exceed this value. Defaults to context-wide value specified in `agent` property.
- `timeout` [number] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="page-agent-extract-option-timeout"/><a href="#page-agent-extract-option-timeout" class="list-anchor">#</a>

Request timeout in milliseconds. Defaults to action timeout. Pass `0` to disable timeout.
Extract timeout in milliseconds. Defaults to `5000`. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout()](/api/class-browsercontext.mdx#browser-context-set-default-timeout) or [page.setDefaultTimeout()](/api/class-page.mdx#page-set-default-timeout) methods. Pass `0` to disable timeout.

**Returns**
- [Promise]&lt;[Object]&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="page-agent-extract-return"/><a href="#page-agent-extract-return" class="list-anchor">#</a>
Expand Down Expand Up @@ -153,7 +153,7 @@ await agent.perform('Click submit button');
Maximum number of tokens to consume. The agentic loop will stop after input + output tokens exceed this value. Defaults to context-wide value specified in `agent` property.
- `timeout` [number] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="page-agent-perform-option-timeout"/><a href="#page-agent-perform-option-timeout" class="list-anchor">#</a>

Request timeout in milliseconds. Defaults to action timeout. Pass `0` to disable timeout.
Perform timeout in milliseconds. Defaults to `5000`. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout()](/api/class-browsercontext.mdx#browser-context-set-default-timeout) or [page.setDefaultTimeout()](/api/class-page.mdx#page-set-default-timeout) methods. Pass `0` to disable timeout.

**Returns**
- [Promise]&lt;[Object]&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="page-agent-perform-return"/><a href="#page-agent-perform-return" class="list-anchor">#</a>
Expand Down
Loading