@@ -785,4 +785,36 @@ await page.GetByText("Click me").ClickAsync(new LocatorClickOptions
785
785
expect . soft ( sources . get ( 'C#' ) ! . text ) . toContain ( `
786
786
await page.GetByRole(AriaRole.Slider).FillAsync("10");` ) ;
787
787
} ) ;
788
+
789
+ test ( 'should click button with nested div' , async ( { page, openRecorder } ) => {
790
+ test . info ( ) . annotations . push ( { type : 'issue' , description : 'https://github.com/microsoft/playwright/issues/29067' } ) ;
791
+
792
+ const recorder = await openRecorder ( ) ;
793
+
794
+ await recorder . setContentAndWait ( `<button><div role="none">Submit</div></button>` ) ;
795
+
796
+ // we hover the nested div, but it must record the button
797
+ const locator = await recorder . hoverOverElement ( 'div' ) ;
798
+ expect ( locator ) . toBe ( `getByRole('button', { name: 'Submit' })` ) ;
799
+
800
+ const [ sources ] = await Promise . all ( [
801
+ recorder . waitForOutput ( 'JavaScript' , 'Submit' ) ,
802
+ recorder . trustedClick ( ) ,
803
+ ] ) ;
804
+
805
+ expect . soft ( sources . get ( 'JavaScript' ) ! . text ) . toContain ( `
806
+ await page.getByRole('button', { name: 'Submit' }).click();` ) ;
807
+
808
+ expect . soft ( sources . get ( 'Python' ) ! . text ) . toContain ( `
809
+ page.get_by_role("button", name="Submit").click()` ) ;
810
+
811
+ expect . soft ( sources . get ( 'Python Async' ) ! . text ) . toContain ( `
812
+ await page.get_by_role("button", name="Submit").click()` ) ;
813
+
814
+ expect . soft ( sources . get ( 'Java' ) ! . text ) . toContain ( `
815
+ page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Submit")).click()` ) ;
816
+
817
+ expect . soft ( sources . get ( 'C#' ) ! . text ) . toContain ( `
818
+ await page.GetByRole(AriaRole.Button, new() { Name = "Submit" }).ClickAsync();` ) ;
819
+ } ) ;
788
820
} ) ;
0 commit comments