import { switchFromHandleToIframe , SwitchToIframeOptions } from '../../handle-actions' ; import { getHandleOf } from '../get-handle-of' ; import { defaultWaitUntilOptions , WaitUntilOptions } from '../../../utils' ; import { getPageFrom } from '../../dom-actions' ; import { Frame , Page } from 'playwright' ; export async function switchFromSelectorToIframe ( selector , pageProviderOrPageInstance , options ) { const pageOrFrame = getPageFrom ( pageProviderOrPageInstance ) ; if ( ! pageOrFrame ) { throw new Error ( `Cannot switch to iframe from '${ selector }' because no browser has been launched` ) ; } const waitOptions = { ... defaultWaitUntilOptions , ... options , } ; const handle = await getHandleOf ( selector , pageProviderOrPageInstance , waitOptions ) ; return switchFromHandleToIframe ( handle , selector , pageProviderOrPageInstance , options ) ; }