| 140 | } |
| 141 | |
| 142 | async waitFor<ElementType extends Element|null = null, Selector extends string = string>( |
| 143 | selector: Selector, root?: puppeteer.ElementHandle, asyncScope = new AsyncScope(), handler?: string) { |
| 144 | return await asyncScope.exec(() => this.waitForFunction(async () => { |
| 145 | const element = await this.$<ElementType, typeof selector>(selector, root, handler); |
| 146 | return (element || undefined); |
| 147 | }, asyncScope, `Waiting for element matching selector '${handler ? `${handler}/` : ''}${selector}'`)); |
| 148 | } |
| 149 | |
| 150 | async performActionOnSelector(selector: string, options: {root?: puppeteer.ElementHandle}, action: Action): |
| 151 | Promise<puppeteer.ElementHandle> { |