(
page: Page,
selector: string,
text?: string | RegExp,
options: number | {timeout?: number; state?: 'visible' | 'attached'} = 5000,
)
| 25 | }; |
| 26 | |
| 27 | export const expectedFramedElement = async ( |
| 28 | page: Page, |
| 29 | selector: string, |
| 30 | text?: string | RegExp, |
| 31 | options: number | {timeout?: number; state?: 'visible' | 'attached'} = 5000, |
| 32 | ): Promise<Locator> => { |
| 33 | const timeout = |
| 34 | typeof options === 'number' ? options : (options.timeout ?? 5000); |
| 35 | const state = |
| 36 | typeof options === 'number' ? 'visible' : (options.state ?? 'visible'); |
| 37 | const frame = page.frameLocator('iframe').first(); |
| 38 | const locator = frame.locator(selector); |
| 39 | |
| 40 | const element = text |
| 41 | ? locator.filter({hasText: text}).first() |
| 42 | : locator.first(); |
| 43 | |
| 44 | if (state === 'visible') { |
| 45 | await expect(element).toBeVisible({timeout}); |
| 46 | } else { |
| 47 | await expect(element).toBeAttached({timeout}); |
| 48 | } |
| 49 | return element; |
| 50 | }; |
| 51 | |
| 52 | export const expectedFramedSvgElement = async ( |
| 53 | page: Page, |
no outgoing calls
searching dependent graphs…