Skip to content

Commit

Permalink
docs: add toHaveAccessibleErrorMessage API
Browse files Browse the repository at this point in the history
  • Loading branch information
pengooseDev committed Dec 7, 2024
1 parent df041e4 commit cccdd97
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
50 changes: 50 additions & 0 deletions docs/src/api/class-locatorassertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,56 @@ Expected accessible description.
* since: v1.44


## async method: LocatorAssertions.toHaveAccessibleErrorMessage
* since: v1.50
* langs:
- alias-java: hasAccessibleErrorMessage

Ensures the [Locator] points to an element with a given [accessible error message](https://www.w3.org/TR/wai-aria-1.2/#aria-errormessage).

**Usage**

```js
const locator = page.getByTestId('username-input');
await expect(locator).toHaveAccessibleErrorMessage('Username is required.');
```

```java
Locator locator = page.getByTestId("username-input");
assertThat(locator).hasAccessibleErrorMessage("Username is required.");
```

```python async
locator = page.get_by_test_id("username-input")
await expect(locator).to_have_accessible_error_message("Username is required.")
```

```python sync
locator = page.get_by_test_id("username-input")
expect(locator).to_have_accessible_error_message("Username is required.")
```

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

### param: LocatorAssertions.toHaveAccessibleErrorMessage.errorMessage
* since: v1.45
- `errorMessage` <[string]|[RegExp]>

Expected accessible error message.

### option: LocatorAssertions.toHaveAccessibleErrorMessage.timeout = %%-js-assertions-timeout-%%
* since: v1.45

### option: LocatorAssertions.toHaveAccessibleErrorMessage.timeout = %%-csharp-java-python-assertions-timeout-%%
* since: v1.45

### option: LocatorAssertions.toHaveAccessibleErrorMessage.ignoreCase = %%-assertions-ignore-case-%%
* since: v1.45


## async method: LocatorAssertions.toHaveAccessibleName
* since: v1.44
* langs:
Expand Down
28 changes: 28 additions & 0 deletions packages/playwright/types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7903,6 +7903,34 @@ interface LocatorAssertions {
timeout?: number;
}): Promise<void>;

/**
* Ensures the [Locator](https://playwright.dev/docs/api/class-locator) points to an element with a given
* [accessible error message](https://www.w3.org/TR/wai-aria-1.2/#aria-errormessage).
*
* **Usage**
*
* ```js
* const locator = page.getByTestId('username-input');
* await expect(locator).toHaveAccessibleErrorMessage('Username is required.');
* ```
*
* @param errorMessage Expected accessible error message.
* @param options
*/
toHaveAccessibleErrorMessage(errorMessage: string|RegExp, options?: {
/**
* Whether to perform case-insensitive match.
* [`ignoreCase`](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-accessible-error-message-option-ignore-case)
* option takes precedence over the corresponding regular expression flag if specified.
*/
ignoreCase?: boolean;

/**
* Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.
*/
timeout?: number;
}): Promise<void>;

/**
* Ensures the [Locator](https://playwright.dev/docs/api/class-locator) points to an element with a given
* [accessible name](https://w3c.github.io/accname/#dfn-accessible-name).
Expand Down

0 comments on commit cccdd97

Please sign in to comment.