File tree Expand file tree Collapse file tree 2 files changed +35
-4
lines changed
Expand file tree Collapse file tree 2 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,14 @@ export const waitFor = defineTool({
3636 } ,
3737 handler : async ( request , response , context ) => {
3838 const page = context . getSelectedPage ( ) ;
39+ const frames = page . frames ( ) ;
3940
40- await Locator . race ( [
41- page . locator ( `aria/${ request . params . text } ` ) ,
42- page . locator ( `text/${ request . params . text } ` ) ,
43- ] ) . wait ( ) ;
41+ const locators = frames . flatMap ( frame => [
42+ frame . locator ( `aria/${ request . params . text } ` ) ,
43+ frame . locator ( `text/${ request . params . text } ` ) ,
44+ ] ) ;
45+
46+ await Locator . race ( locators ) . wait ( ) ;
4447
4548 response . appendResponseLine (
4649 `Element with text "${ request . params . text } " found.` ,
Original file line number Diff line number Diff line change @@ -95,5 +95,33 @@ describe('snapshot', () => {
9595 assert . ok ( response . includeSnapshot ) ;
9696 } ) ;
9797 } ) ;
98+
99+
100+ it ( 'should work with iframe content' , async ( ) => {
101+ await withBrowser ( async ( response , context ) => {
102+ const page = await context . getSelectedPage ( ) ;
103+
104+ await page . setContent (
105+ html `< h1 > Top level</ h1 >
106+ < iframe srcdoc ="<p>Hello iframe</p> "> </ iframe > ` ,
107+ ) ;
108+
109+ await waitFor . handler (
110+ {
111+ params : {
112+ text : 'Hello iframe' ,
113+ } ,
114+ } ,
115+ response ,
116+ context ,
117+ ) ;
118+
119+ assert . equal (
120+ response . responseLines [ 0 ] ,
121+ 'Element with text "Hello iframe" found.' ,
122+ ) ;
123+ assert . ok ( response . includeSnapshot ) ;
124+ } ) ;
125+ } ) ;
98126 } ) ;
99127} ) ;
You can’t perform that action at this time.
0 commit comments