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
fix(codgen): assertValue works with disabled select (#31315)
4ydx4089f4593b34
diff --git a/packages/playwright-core/src/server/injected/recorder/recorder.ts b/packages/playwright-core/src/server/injected/recorder/recorder.tsindex 261a0eab21..4cfa512a4f 100644--- a/packages/playwright-core/src/server/injected/recorder/recorder.ts+++ b/packages/playwright-core/src/server/injected/recorder/recorder.ts@@ -578,8 +578,8 @@ class TextAssertionTool implements RecorderTool {onPointerUp(event: PointerEvent) {const target = this._hoverHighlight?.elements[0];- if (this._kind === 'value' && target && target.nodeName === 'INPUT' && (target as HTMLInputElement).disabled) {- // Click on a disabled input does not produce a "click" event, but we still want+ if (this._kind === 'value' && target && (target.nodeName === 'INPUT' || target.nodeName === 'SELECT') && (target as HTMLInputElement).disabled) {+ // Click on a disabled input (or select) does not produce a "click" event, but we still want// to assert the value.this._commitAssertValue();}diff --git a/tests/library/inspector/cli-codegen-3.spec.ts b/tests/library/inspector/cli-codegen-3.spec.tsindex 96a6295f13..2c0fff974a 100644--- a/tests/library/inspector/cli-codegen-3.spec.ts+++ b/tests/library/inspector/cli-codegen-3.spec.ts@@ -631,6 +631,27 @@ await page.GetByLabel("Coun\\"try").ClickAsync();`);expect.soft(sources2.get('C#')!.text).toContain(`await Expect(page.Locator("#second")).ToHaveValueAsync("bar")`);});+ test('should assert value on disabled select', async ({ openRecorder, browserName }) => {+ const recorder = await openRecorder();++ await recorder.setContentAndWait(`+ <select id=first><option value=foo1>Foo1</option><option value=bar1>Bar1</option></select>+ <select id=second disabled><option value=foo2>Foo2</option><option value=bar2 selected>Bar2</option></select>+ `);++ await recorder.page.click('x-pw-tool-item.value');+ await recorder.hoverOverElement('#second');+ const [sources2] = await Promise.all([+ recorder.waitForOutput('JavaScript', '#second'),+ recorder.trustedClick(),+ ]);+ expect.soft(sources2.get('JavaScript')!.text).toContain(`await expect(page.locator('#second')).toHaveValue('bar2')`);+ expect.soft(sources2.get('Python')!.text).toContain(`expect(page.locator("#second")).to_have_value("bar2")`);+ expect.soft(sources2.get('Python Async')!.text).toContain(`await expect(page.locator("#second")).to_have_value("bar2")`);+ expect.soft(sources2.get('Java')!.text).toContain(`assertThat(page.locator("#second")).hasValue("bar2")`);+ expect.soft(sources2.get('C#')!.text).toContain(`await Expect(page.Locator("#second")).ToHaveValueAsync("bar2")`);+ });+test('should assert visibility', async ({ openRecorder }) => {const recorder = await openRecorder();