File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
packages/playwright-core/src/server/injected/recorder Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -578,8 +578,8 @@ class TextAssertionTool implements RecorderTool {
578578
579579 onPointerUp ( event : PointerEvent ) {
580580 const target = this . _hoverHighlight ?. elements [ 0 ] ;
581- if ( this . _kind === 'value' && target && target . nodeName === 'INPUT' && ( target as HTMLInputElement ) . disabled ) {
582- // Click on a disabled input does not produce a "click" event, but we still want
581+ if ( this . _kind === 'value' && target && ( target . nodeName === 'INPUT' || target . nodeName === 'SELECT' ) && ( target as HTMLInputElement ) . disabled ) {
582+ // Click on a disabled input (or select) does not produce a "click" event, but we still want
583583 // to assert the value.
584584 this . _commitAssertValue ( ) ;
585585 }
Original file line number Diff line number Diff line change @@ -631,6 +631,27 @@ await page.GetByLabel("Coun\\"try").ClickAsync();`);
631631 expect . soft ( sources2 . get ( 'C#' ) ! . text ) . toContain ( `await Expect(page.Locator("#second")).ToHaveValueAsync("bar")` ) ;
632632 } ) ;
633633
634+ test ( 'should assert value on disabled select' , async ( { openRecorder, browserName } ) => {
635+ const recorder = await openRecorder ( ) ;
636+
637+ await recorder . setContentAndWait ( `
638+ <select id=first><option value=foo1>Foo1</option><option value=bar1>Bar1</option></select>
639+ <select id=second disabled><option value=foo2>Foo2</option><option value=bar2 selected>Bar2</option></select>
640+ ` ) ;
641+
642+ await recorder . page . click ( 'x-pw-tool-item.value' ) ;
643+ await recorder . hoverOverElement ( '#second' ) ;
644+ const [ sources2 ] = await Promise . all ( [
645+ recorder . waitForOutput ( 'JavaScript' , '#second' ) ,
646+ recorder . trustedClick ( ) ,
647+ ] ) ;
648+ expect . soft ( sources2 . get ( 'JavaScript' ) ! . text ) . toContain ( `await expect(page.locator('#second')).toHaveValue('bar2')` ) ;
649+ expect . soft ( sources2 . get ( 'Python' ) ! . text ) . toContain ( `expect(page.locator("#second")).to_have_value("bar2")` ) ;
650+ expect . soft ( sources2 . get ( 'Python Async' ) ! . text ) . toContain ( `await expect(page.locator("#second")).to_have_value("bar2")` ) ;
651+ expect . soft ( sources2 . get ( 'Java' ) ! . text ) . toContain ( `assertThat(page.locator("#second")).hasValue("bar2")` ) ;
652+ expect . soft ( sources2 . get ( 'C#' ) ! . text ) . toContain ( `await Expect(page.Locator("#second")).ToHaveValueAsync("bar2")` ) ;
653+ } ) ;
654+
634655 test ( 'should assert visibility' , async ( { openRecorder } ) => {
635656 const recorder = await openRecorder ( ) ;
636657
You can’t perform that action at this time.
0 commit comments