| 92 | } |
| 93 | |
| 94 | export class Page< |
| 95 | AgentType extends 'puppeteer' | 'playwright', |
| 96 | InterfaceType extends PuppeteerPage | PlaywrightPage, |
| 97 | > implements AbstractInterface |
| 98 | { |
| 99 | underlyingPage: InterfaceType; |
| 100 | protected waitForNavigationTimeout: number; |
| 101 | protected waitForNetworkIdleTimeout: number; |
| 102 | private viewportSize?: Size; |
| 103 | private onBeforeInvokeAction?: AbstractInterface['beforeInvokeAction']; |
| 104 | private onAfterInvokeAction?: AbstractInterface['afterInvokeAction']; |
| 105 | private customActions?: DeviceAction<any>[]; |
| 106 | private enableTouchEventsInActionSpace: boolean; |
| 107 | private keyboardTypeDelay: number | undefined; |
| 108 | private puppeteerFileChooserSession?: CDPSession; |
| 109 | private puppeteerFileChooserHandler?: ( |
| 110 | event: Protocol.Page.FileChooserOpenedEvent, |
| 111 | ) => Promise<void>; |
| 112 | private playwrightNetworkIdleWarningShown = false; |
| 113 | private activeMjpegStream?: { |
| 114 | token: symbol; |
| 115 | onFrame: MjpegStreamOptions['onFrame']; |
| 116 | onError?: MjpegStreamOptions['onError']; |
| 117 | }; |
| 118 | private visualUpdateFlushInFlight: Promise<void> | null = null; |
| 119 | private visualUpdateFlushQueued = false; |
| 120 | interfaceType: AgentType; |
| 121 | |
| 122 | actionSpace(): DeviceAction[] { |
| 123 | const defaultActions = commonWebActionsForWebPage( |
| 124 | this, |
| 125 | this.enableTouchEventsInActionSpace, |
| 126 | ); |
| 127 | const customActions = this.customActions || []; |
| 128 | return [...defaultActions, ...customActions]; |
| 129 | } |
| 130 | |
| 131 | private async evaluate<R>( |
| 132 | pageFunction: string | ((...args: any[]) => R | Promise<R>), |
| 133 | arg?: any, |
| 134 | ): Promise<R> { |
| 135 | let result: R; |
| 136 | debugPage('evaluate function begin'); |
| 137 | if (this.interfaceType === 'puppeteer') { |
| 138 | result = await (this.underlyingPage as PuppeteerPage).evaluate( |
| 139 | pageFunction, |
| 140 | arg, |
| 141 | ); |
| 142 | } else { |
| 143 | result = await (this.underlyingPage as PlaywrightPage).evaluate( |
| 144 | pageFunction, |
| 145 | arg, |
| 146 | ); |
| 147 | } |
| 148 | debugPage('evaluate function end'); |
| 149 | return result; |
| 150 | } |
| 151 |
nothing calls this directly
no outgoing calls
no test coverage detected