From f123f7ac690f9184f0781c47950924e0094f605e Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Fri, 22 Nov 2024 11:40:43 +0000 Subject: [PATCH] fix: isEditable/toBeEditable throw for elements that cannot be editable/readonly (#33713) --- docs/src/actionability.md | 13 +++++++++++-- docs/src/api/class-locator.md | 2 +- .../src/server/injected/injectedScript.ts | 11 +++++++---- .../src/server/injected/roleUtils.ts | 15 +++++++++++++++ packages/playwright-core/types/types.d.ts | 4 +++- tests/page/expect-boolean.spec.ts | 7 +++++++ tests/page/locator-convenience.spec.ts | 15 ++++++++++++++- tests/page/page-fill.spec.ts | 4 ++-- 8 files changed, 60 insertions(+), 11 deletions(-) diff --git a/docs/src/actionability.md b/docs/src/actionability.md index 4a84f5f5b2..3510171e5c 100644 --- a/docs/src/actionability.md +++ b/docs/src/actionability.md @@ -93,11 +93,20 @@ Element is considered stable when it has maintained the same bounding box for at ## Enabled -Element is considered enabled unless it is a ` + `); await page.$eval('textarea', t => t.readOnly = true); const input1 = page.locator('#input1'); expect(await input1.isEditable()).toBe(false); @@ -130,6 +138,11 @@ it('isEditable should work', async ({ page }) => { const textarea = page.locator('textarea'); expect(await textarea.isEditable()).toBe(false); expect(await page.isEditable('textarea')).toBe(false); + expect(await page.locator('div').isEditable()).toBe(true); + expect(await page.locator('#span1').isEditable()).toBe(false); + expect(await page.locator('#span2').isEditable()).toBe(true); + const error = await page.locator('button').isEditable().catch(e => e); + expect(error.message).toContain('Element is not an ,