docs: add toHaveAccessibleErrorMessage API
This commit is contained in:
parent
b3e3545383
commit
1106e34941
|
|
@ -1217,6 +1217,56 @@ Expected accessible description.
|
||||||
* since: v1.44
|
* 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.50
|
||||||
|
- `errorMessage` <[string]|[RegExp]>
|
||||||
|
|
||||||
|
Expected accessible error message.
|
||||||
|
|
||||||
|
### option: LocatorAssertions.toHaveAccessibleErrorMessage.timeout = %%-js-assertions-timeout-%%
|
||||||
|
* since: v1.50
|
||||||
|
|
||||||
|
### option: LocatorAssertions.toHaveAccessibleErrorMessage.timeout = %%-csharp-java-python-assertions-timeout-%%
|
||||||
|
* since: v1.50
|
||||||
|
|
||||||
|
### option: LocatorAssertions.toHaveAccessibleErrorMessage.ignoreCase = %%-assertions-ignore-case-%%
|
||||||
|
* since: v1.50
|
||||||
|
|
||||||
|
|
||||||
## async method: LocatorAssertions.toHaveAccessibleName
|
## async method: LocatorAssertions.toHaveAccessibleName
|
||||||
* since: v1.44
|
* since: v1.44
|
||||||
* langs:
|
* langs:
|
||||||
|
|
|
||||||
28
packages/playwright/types/test.d.ts
vendored
28
packages/playwright/types/test.d.ts
vendored
|
|
@ -8112,6 +8112,34 @@ interface LocatorAssertions {
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
}): Promise<void>;
|
}): 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
|
* 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).
|
* [accessible name](https://w3c.github.io/accname/#dfn-accessible-name).
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue