UNPKG

puppeteer

Version:

A high-level API to control headless Chrome over the DevTools Protocol

149 lines 6.72 kB
/** * Copyright 2017 Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { EventEmitter } from './EventEmitter'; import { ExecutionContext } from './ExecutionContext'; import { PuppeteerLifeCycleEvent } from './LifecycleWatcher'; import { DOMWorld, WaitForSelectorOptions } from './DOMWorld'; import { NetworkManager } from './NetworkManager'; import { TimeoutSettings } from './TimeoutSettings'; import { CDPSession } from './Connection'; import { JSHandle, ElementHandle } from './JSHandle'; import { MouseButton } from './Input'; import { Page } from './Page'; import { HTTPResponse } from './HTTPResponse'; import Protocol from '../protocol'; import { EvaluateFn, SerializableOrJSHandle, EvaluateHandleFn, WrapElementHandle } from './EvalTypes'; export declare class FrameManager extends EventEmitter { _client: CDPSession; _page: Page; _networkManager: NetworkManager; _timeoutSettings: TimeoutSettings; _frames: Map<string, Frame>; _contextIdToContext: Map<number, ExecutionContext>; _isolatedWorlds: Set<string>; _mainFrame: Frame; constructor(client: CDPSession, page: Page, ignoreHTTPSErrors: boolean, timeoutSettings: TimeoutSettings); initialize(): Promise<void>; networkManager(): NetworkManager; navigateFrame(frame: Frame, url: string, options?: { referer?: string; timeout?: number; waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[]; }): Promise<HTTPResponse | null>; waitForFrameNavigation(frame: Frame, options?: { timeout?: number; waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[]; }): Promise<HTTPResponse | null>; _onLifecycleEvent(event: Protocol.Page.lifecycleEventPayload): void; _onFrameStoppedLoading(frameId: string): void; _handleFrameTree(frameTree: Protocol.Page.FrameTree): void; page(): Page; mainFrame(): Frame; frames(): Frame[]; frame(frameId: string): Frame | null; _onFrameAttached(frameId: string, parentFrameId?: string): void; _onFrameNavigated(framePayload: Protocol.Page.Frame): void; _ensureIsolatedWorld(name: string): Promise<void>; _onFrameNavigatedWithinDocument(frameId: string, url: string): void; _onFrameDetached(frameId: string): void; _onExecutionContextCreated(contextPayload: Protocol.Runtime.ExecutionContextDescription): void; /** * @param {number} executionContextId */ _onExecutionContextDestroyed(executionContextId: number): void; _onExecutionContextsCleared(): void; executionContextById(contextId: number): ExecutionContext; _removeFramesRecursively(frame: Frame): void; } export declare class Frame { _frameManager: FrameManager; _client: CDPSession; _parentFrame?: Frame; _id: string; _url: string; _detached: boolean; _loaderId: string; _name?: string; _lifecycleEvents: Set<string>; _mainWorld: DOMWorld; _secondaryWorld: DOMWorld; _childFrames: Set<Frame>; constructor(frameManager: FrameManager, client: CDPSession, parentFrame: Frame | null, frameId: string); goto(url: string, options?: { referer?: string; timeout?: number; waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[]; }): Promise<HTTPResponse | null>; waitForNavigation(options?: { timeout?: number; waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[]; }): Promise<HTTPResponse | null>; executionContext(): Promise<ExecutionContext>; evaluateHandle<HandlerType extends JSHandle = JSHandle>(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise<HandlerType>; evaluate<ReturnType extends any>(pageFunction: Function | string, ...args: unknown[]): Promise<ReturnType>; $(selector: string): Promise<ElementHandle | null>; $x(expression: string): Promise<ElementHandle[]>; $eval<ReturnType>(selector: string, pageFunction: (element: Element, ...args: unknown[]) => ReturnType | Promise<ReturnType>, ...args: SerializableOrJSHandle[]): Promise<WrapElementHandle<ReturnType>>; $$eval<ReturnType extends any>(selector: string, pageFunction: EvaluateFn | string, ...args: SerializableOrJSHandle[]): Promise<ReturnType>; $$(selector: string): Promise<ElementHandle[]>; content(): Promise<string>; setContent(html: string, options?: { timeout?: number; waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[]; }): Promise<void>; name(): string; url(): string; parentFrame(): Frame | null; childFrames(): Frame[]; isDetached(): boolean; addScriptTag(options: { url?: string; path?: string; content?: string; type?: string; }): Promise<ElementHandle>; addStyleTag(options: { url?: string; path?: string; content?: string; }): Promise<ElementHandle>; click(selector: string, options?: { delay?: number; button?: MouseButton; clickCount?: number; }): Promise<void>; focus(selector: string): Promise<void>; hover(selector: string): Promise<void>; select(selector: string, ...values: string[]): Promise<string[]>; tap(selector: string): Promise<void>; type(selector: string, text: string, options?: { delay: number; }): Promise<void>; waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {}, ...args: SerializableOrJSHandle[]): Promise<JSHandle | null>; waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise<ElementHandle | null>; waitForXPath(xpath: string, options?: WaitForSelectorOptions): Promise<ElementHandle | null>; waitForFunction(pageFunction: Function | string, options?: { polling?: string | number; timeout?: number; }, ...args: SerializableOrJSHandle[]): Promise<JSHandle>; title(): Promise<string>; _navigated(framePayload: Protocol.Page.Frame): void; _navigatedWithinDocument(url: string): void; _onLifecycleEvent(loaderId: string, name: string): void; _onLoadingStopped(): void; _detach(): void; } //# sourceMappingURL=FrameManager.d.ts.map