parent
47733b04fb
commit
0ade5aa9ad
|
|
@ -1151,6 +1151,12 @@ Expected attribute value.
|
||||||
### option: LocatorAssertions.toHaveAttribute.timeout = %%-csharp-java-python-assertions-timeout-%%
|
### option: LocatorAssertions.toHaveAttribute.timeout = %%-csharp-java-python-assertions-timeout-%%
|
||||||
* since: v1.18
|
* since: v1.18
|
||||||
|
|
||||||
|
### option: LocatorAssertions.toHaveAttribute.ignoreCase = %%-js-assertions-timeout-%%
|
||||||
|
* since: v1.40
|
||||||
|
- `ignoreCase` <[boolean]>
|
||||||
|
|
||||||
|
Whether to perform case-insensitive match. [`option: ignoreCase`] option takes precedence over the corresponding regular expression flag if specified.
|
||||||
|
|
||||||
## async method: LocatorAssertions.toHaveAttribute#2
|
## async method: LocatorAssertions.toHaveAttribute#2
|
||||||
* since: v1.39
|
* since: v1.39
|
||||||
* langs: js
|
* langs: js
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ export function toHaveAttribute(
|
||||||
locator: LocatorEx,
|
locator: LocatorEx,
|
||||||
name: string,
|
name: string,
|
||||||
expected: string | RegExp | undefined | { timeout?: number },
|
expected: string | RegExp | undefined | { timeout?: number },
|
||||||
options?: { timeout?: number },
|
options?: { timeout?: number, ignoreCase?: boolean },
|
||||||
) {
|
) {
|
||||||
if (!options) {
|
if (!options) {
|
||||||
// Update params for the case toHaveAttribute(name, options);
|
// Update params for the case toHaveAttribute(name, options);
|
||||||
|
|
@ -193,7 +193,7 @@ export function toHaveAttribute(
|
||||||
}, options);
|
}, options);
|
||||||
}
|
}
|
||||||
return toMatchText.call(this, 'toHaveAttribute', locator, 'Locator', async (isNot, timeout) => {
|
return toMatchText.call(this, 'toHaveAttribute', locator, 'Locator', async (isNot, timeout) => {
|
||||||
const expectedText = toExpectedTextValues([expected as (string | RegExp)]);
|
const expectedText = toExpectedTextValues([expected as (string | RegExp)], { ignoreCase: options?.ignoreCase });
|
||||||
return await locator._expect('to.have.attribute.value', { expressionArg: name, expectedText, isNot, timeout });
|
return await locator._expect('to.have.attribute.value', { expressionArg: name, expectedText, isNot, timeout });
|
||||||
}, expected as (string | RegExp), options);
|
}, expected as (string | RegExp), options);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
packages/playwright/types/test.d.ts
vendored
8
packages/playwright/types/test.d.ts
vendored
|
|
@ -5708,6 +5708,14 @@ interface LocatorAssertions {
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
toHaveAttribute(name: string, value: string|RegExp, options?: {
|
toHaveAttribute(name: string, value: string|RegExp, options?: {
|
||||||
|
/**
|
||||||
|
* Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.
|
||||||
|
*
|
||||||
|
* Whether to perform case-insensitive match. `ignoreCase` 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`.
|
* Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,13 @@ test.describe('toHaveAttribute', () => {
|
||||||
await expect(locator).toHaveAttribute('checked', { timeout: 5000 });
|
await expect(locator).toHaveAttribute('checked', { timeout: 5000 });
|
||||||
await expect(locator).not.toHaveAttribute('open', { timeout: 5000 });
|
await expect(locator).not.toHaveAttribute('open', { timeout: 5000 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('support ignoreCase', async ({ page }) => {
|
||||||
|
await page.setContent('<div id=NoDe>Text content</div>');
|
||||||
|
const locator = page.locator('#NoDe');
|
||||||
|
await expect(locator).toHaveAttribute('id', 'node', { ignoreCase: true });
|
||||||
|
await expect(locator).not.toHaveAttribute('id', 'node');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe('toHaveCSS', () => {
|
test.describe('toHaveCSS', () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue