@@ -121,6 +121,29 @@ abstract class ControllableBase {
121121 throw Error ( `waiting failed: Elements did not receive the focus: ${ selector } ` ) ;
122122 } ;
123123
124+ /**
125+ * Wait for iframes to be present on the page with retry logic.
126+ * This is useful in CI environments where iframe injection can be slower.
127+ * @param maxAttempts - Maximum number of retry attempts (default: 3)
128+ * @param timeoutPerAttempt - Timeout in seconds for each attempt (default: 20)
129+ * @returns Promise that resolves when iframes are found
130+ */
131+ public waitForIframes = async ( maxAttempts = 3 , timeoutPerAttempt = 20 ) : Promise < void > => {
132+ for ( let attempt = 1 ; attempt <= maxAttempts ; attempt ++ ) {
133+ try {
134+ await this . waitAll ( 'iframe' , { timeout : timeoutPerAttempt } ) ;
135+ return ; // Success - iframes found
136+ } catch {
137+ if ( attempt === maxAttempts ) {
138+ throw new Error ( `Failed to find iframes after ${ maxAttempts } attempts with ${ timeoutPerAttempt } s timeout each` ) ;
139+ }
140+ // Log and retry
141+ console . log ( `Attempt ${ attempt } /${ maxAttempts } : iframes not found yet, retrying...` ) ;
142+ await Util . sleep ( 1 ) ; // Brief wait before retry
143+ }
144+ }
145+ } ;
146+
124147 public notPresent = async ( selector : string | string [ ] ) => {
125148 return await this . waitTillGone ( selector , { timeout : 0 } ) ;
126149 } ;
@@ -404,7 +427,7 @@ abstract class ControllableBase {
404427 }
405428 throw new Error (
406429 `Selector ${ selector } was found but did not match "${ needle } " within ${ timeoutSec } s. ` +
407- `Observed content history: "${ JSON . stringify ( observedContentHistory , undefined , 2 ) } "`
430+ `Observed content history: "${ JSON . stringify ( observedContentHistory , undefined , 2 ) } "`
408431 ) ;
409432 } ;
410433
@@ -716,7 +739,7 @@ class ConsoleEvent {
716739 public constructor (
717740 public type : string ,
718741 public text : string
719- ) { }
742+ ) { }
720743}
721744
722745export class ControllablePage extends ControllableBase {
0 commit comments