Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
docs: clarify toBeDisabled behavior (#13616)
Yury Semikhatskyed0dcdabc9ff
diff --git a/docs/src/api/class-locatorassertions.md b/docs/src/api/class-locatorassertions.mdindex afb259b9b6..9282c34a1b 100644--- a/docs/src/api/class-locatorassertions.md+++ b/docs/src/api/class-locatorassertions.md@@ -337,7 +337,11 @@ await Expect(locator).ToBeCheckedAsync();* langs:- alias-java: isDisabled-Ensures the [Locator] points to a disabled element.+Ensures the [Locator] points to a disabled element. Element is disabled if it has "disabled" attribute+or is disabled via ['aria-disabled'](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled).+Note that only native control elements such as HTML `button`, `input`, `select`, `textarea`, `option`, `optgroup`+can be disabled by setting "disabled" attribute. "disabled" attribute on other elements is ignored+by the browser.```jsconst locator = page.locator('button.submit');diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.tsindex 14e8812b13..98261cff1c 100644--- a/packages/playwright-test/types/test.d.ts+++ b/packages/playwright-test/types/test.d.ts@@ -3163,7 +3163,10 @@ interface LocatorAssertions {}): Promise<void>;/**- * Ensures the [Locator] points to a disabled element.+ * Ensures the [Locator] points to a disabled element. Element is disabled if it has "disabled" attribute or is disabled+ * via ['aria-disabled'](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled). Note+ * that only native control elements such as HTML `button`, `input`, `select`, `textarea`, `option`, `optgroup` can be+ * disabled by setting "disabled" attribute. "disabled" attribute on other elements is ignored by the browser.** ```js* const locator = page.locator('button.submit');diff --git a/tests/config/experimental.d.ts b/tests/config/experimental.d.tsindex 32976f9d6a..1525ad4f11 100644--- a/tests/config/experimental.d.ts+++ b/tests/config/experimental.d.ts@@ -19368,7 +19368,10 @@ interface LocatorAssertions {}): Promise<void>;/**- * Ensures the [Locator] points to a disabled element.+ * Ensures the [Locator] points to a disabled element. Element is disabled if it has "disabled" attribute or is disabled+ * via ['aria-disabled'](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled). Note+ * that only native control elements such as HTML `button`, `input`, `select`, `textarea`, `option`, `optgroup` can be+ * disabled by setting "disabled" attribute. "disabled" attribute on other elements is ignored by the browser.** ```js* const locator = page.locator('button.submit');diff --git a/tests/playwright-test/playwright.expect.true.spec.ts b/tests/playwright-test/playwright.expect.true.spec.tsindex 0328e4bf34..c74c2386ca 100644--- a/tests/playwright-test/playwright.expect.true.spec.ts+++ b/tests/playwright-test/playwright.expect.true.spec.ts@@ -176,6 +176,39 @@ test('should support toBeEditable, toBeEnabled, toBeDisabled, toBeEmpty', asyncexpect(output).toContain('expect(locator).toBeEnabled({ timeout: 500 }');});+test('should support toBeDisabled,toBeChecked,toBeHidden w/ value', async ({ runInlineTest }) => {+ const result = await runInlineTest({+ 'a.test.ts': `+ const { test } = pwt;++ test('disabled', async ({ page }) => {+ await page.setContent('<button disabled="yes">Text</button>');+ const locator = page.locator('button');+ await expect(locator).toBeDisabled();+ });+ test('checked', async ({ page }) => {+ await page.setContent('<input type=checkbox checked="yes"></input>');+ const locator = page.locator('input');+ await expect(locator).toBeChecked();+ });+ test('hidden', async ({ page }) => {+ await page.setContent('<input type=checkbox hidden="of course"></input>');+ const locator = page.locator('input');+ await expect(locator).toBeHidden();+ });+ test('div disabled', async ({ page }) => {+ await page.setContent('<div disabled="yes"></div>');+ const locator = page.locator('div');+ await expect(locator).not.toBeDisabled();+ });+ `,+ }, { workers: 1 });+ expect(result.passed).toBe(4);+ expect(result.failed).toBe(0);+ expect(result.exitCode).toBe(0);+});++test('should support toBeVisible, toBeHidden', async ({ runInlineTest }) => {const result = await runInlineTest({'a.test.ts': `