import { MethodName , invokeMethodOnHandle } from '../../handle-actions' ; import { getHandleOf } from '../get-handle-of' ; import { WaitUntilOptions , defaultWaitUntilOptions } from '../../../utils' ; import { Frame , Page } from 'playwright' ; export interface InvokeOptions { stabilityInMilliseconds : number ; timeoutInMilliseconds : number ; verbose : boolean ; } export const defaultInvokeOptions = { stabilityInMilliseconds : 300 , timeoutInMilliseconds : 30000 , verbose : false , } ; export async function invokeMethodOnSelector ( methodName , selector , page , options ) { if ( ! page ) { throw new Error ( `Cannot invoke method '${ methodName }' on '${ selector }' because no browser has been launched` ) ; } const waitOptions = { ... defaultWaitUntilOptions , ... options , } ; const handle = await getHandleOf ( selector , page , waitOptions ) ; await invokeMethodOnHandle ( methodName , handle , selector ) ; }