@@ -65,7 +65,9 @@ export class FrameExecutionContext extends js.ExecutionContext {
65
65
} ) ) ;
66
66
let result ;
67
67
try {
68
- result = await this . _delegate . evaluate ( this , returnByValue , pageFunction , ...adopted ) ;
68
+ result = await this . frame . _page . _frameManager . waitForNavigationsCreatedBy ( async ( ) => {
69
+ return this . _delegate . evaluate ( this , returnByValue , pageFunction , ...adopted ) ;
70
+ } ) ;
69
71
} finally {
70
72
await Promise . all ( toDispose . map ( handlePromise => handlePromise . then ( handle => handle . dispose ( ) ) ) ) ;
71
73
}
@@ -248,12 +250,15 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
248
250
const point = offset ? await this . _offsetPoint ( offset ) : await this . _clickablePoint ( ) ;
249
251
if ( waitFor )
250
252
await this . _waitForHitTargetAt ( point , options ) ;
251
- let restoreModifiers : input . Modifier [ ] | undefined ;
252
- if ( options && options . modifiers )
253
- restoreModifiers = await this . _page . keyboard . _ensureModifiers ( options . modifiers ) ;
254
- await action ( point ) ;
255
- if ( restoreModifiers )
256
- await this . _page . keyboard . _ensureModifiers ( restoreModifiers ) ;
253
+
254
+ await this . _page . _frameManager . waitForNavigationsCreatedBy ( async ( ) => {
255
+ let restoreModifiers : input . Modifier [ ] | undefined ;
256
+ if ( options && options . modifiers )
257
+ restoreModifiers = await this . _page . keyboard . _ensureModifiers ( options . modifiers ) ;
258
+ await action ( point ) ;
259
+ if ( restoreModifiers )
260
+ await this . _page . keyboard . _ensureModifiers ( restoreModifiers ) ;
261
+ } ) ;
257
262
}
258
263
259
264
hover ( options ?: PointerActionOptions & types . WaitForOptions ) : Promise < void > {
@@ -284,18 +289,22 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
284
289
if ( option . index !== undefined )
285
290
assert ( helper . isNumber ( option . index ) , 'Indices must be numbers. Found index "' + option . index + '" of type "' + ( typeof option . index ) + '"' ) ;
286
291
}
287
- return this . _evaluateInUtility ( ( injected , node , ...optionsToSelect ) => injected . selectOptions ( node , optionsToSelect ) , ...options ) ;
292
+ return await this . _page . _frameManager . waitForNavigationsCreatedBy < string [ ] > ( async ( ) => {
293
+ return this . _evaluateInUtility ( ( injected , node , ...optionsToSelect ) => injected . selectOptions ( node , optionsToSelect ) , ...options ) ;
294
+ } ) ;
288
295
}
289
296
290
297
async fill ( value : string ) : Promise < void > {
291
298
assert ( helper . isString ( value ) , 'Value must be string. Found value "' + value + '" of type "' + ( typeof value ) + '"' ) ;
292
- const error = await this . _evaluateInUtility ( ( injected , node , value ) => injected . fill ( node , value ) , value ) ;
293
- if ( error )
294
- throw new Error ( error ) ;
295
- if ( value )
296
- await this . _page . keyboard . sendCharacters ( value ) ;
297
- else
298
- await this . _page . keyboard . press ( 'Delete' ) ;
299
+ await this . _page . _frameManager . waitForNavigationsCreatedBy ( async ( ) => {
300
+ const error = await this . _evaluateInUtility ( ( injected , node , value ) => injected . fill ( node , value ) , value ) ;
301
+ if ( error )
302
+ throw new Error ( error ) ;
303
+ if ( value )
304
+ await this . _page . keyboard . sendCharacters ( value ) ;
305
+ else
306
+ await this . _page . keyboard . press ( 'Delete' ) ;
307
+ } ) ;
299
308
}
300
309
301
310
async setInputFiles ( ...files : ( string | types . FilePayload ) [ ] ) {
@@ -317,7 +326,9 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
317
326
}
318
327
return item ;
319
328
} ) ) ;
320
- await this . _page . _delegate . setInputFiles ( this as any as ElementHandle < HTMLInputElement > , filePayloads ) ;
329
+ await this . _page . _frameManager . waitForNavigationsCreatedBy ( async ( ) => {
330
+ await this . _page . _delegate . setInputFiles ( this as any as ElementHandle < HTMLInputElement > , filePayloads ) ;
331
+ } ) ;
321
332
}
322
333
323
334
async focus ( ) {
@@ -332,13 +343,17 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
332
343
}
333
344
334
345
async type ( text : string , options ?: { delay ?: number } ) {
335
- await this . focus ( ) ;
336
- await this . _page . keyboard . type ( text , options ) ;
346
+ await this . _page . _frameManager . waitForNavigationsCreatedBy ( async ( ) => {
347
+ await this . focus ( ) ;
348
+ await this . _page . keyboard . type ( text , options ) ;
349
+ } ) ;
337
350
}
338
351
339
352
async press ( key : string , options ?: { delay ?: number , text ?: string } ) {
340
- await this . focus ( ) ;
341
- await this . _page . keyboard . press ( key , options ) ;
353
+ await this . _page . _frameManager . waitForNavigationsCreatedBy ( async ( ) => {
354
+ await this . focus ( ) ;
355
+ await this . _page . keyboard . press ( key , options ) ;
356
+ } ) ;
342
357
}
343
358
344
359
async check ( options ?: types . WaitForOptions ) {
@@ -352,9 +367,11 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
352
367
private async _setChecked ( state : boolean , options ?: types . WaitForOptions ) {
353
368
if ( await this . _evaluateInUtility ( ( injected , node ) => injected . isCheckboxChecked ( node ) ) === state )
354
369
return ;
355
- await this . click ( options ) ;
356
- if ( await this . _evaluateInUtility ( ( injected , node ) => injected . isCheckboxChecked ( node ) ) !== state )
357
- throw new Error ( 'Unable to click checkbox' ) ;
370
+ await this . _page . _frameManager . waitForNavigationsCreatedBy ( async ( ) => {
371
+ await this . click ( options ) ;
372
+ if ( await this . _evaluateInUtility ( ( injected , node ) => injected . isCheckboxChecked ( node ) ) !== state )
373
+ throw new Error ( 'Unable to click checkbox' ) ;
374
+ } ) ;
358
375
}
359
376
360
377
async boundingBox ( ) : Promise < types . Rect | null > {
0 commit comments