2020-06-25 16:05:36 -07:00
|
|
|
/**
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* 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 'events';
|
|
|
|
import * as types from '../types';
|
|
|
|
|
2020-06-29 16:37:38 -07:00
|
|
|
export type Binary = string;
|
|
|
|
|
2020-06-25 16:05:36 -07:00
|
|
|
export interface Channel extends EventEmitter {
|
|
|
|
}
|
|
|
|
|
2020-07-08 18:42:04 -07:00
|
|
|
export interface PlaywrightChannel extends Channel {
|
|
|
|
}
|
|
|
|
export type PlaywrightInitializer = {
|
|
|
|
chromium: BrowserTypeChannel,
|
|
|
|
firefox: BrowserTypeChannel,
|
|
|
|
webkit: BrowserTypeChannel,
|
2020-07-13 21:46:59 -07:00
|
|
|
electron?: ElectronChannel,
|
2020-07-08 18:42:04 -07:00
|
|
|
deviceDescriptors: types.Devices,
|
2020-07-13 17:47:15 -07:00
|
|
|
selectors: SelectorsChannel,
|
2020-07-08 18:42:04 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-07-13 17:47:15 -07:00
|
|
|
export interface SelectorsChannel extends Channel {
|
|
|
|
register(params: { name: string, source: string, options: { contentScript?: boolean } }): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
createSelector(params: { name: string, handle: ElementHandleChannel }): Promise<{ value?: string }>;
|
2020-07-13 17:47:15 -07:00
|
|
|
}
|
|
|
|
export type SelectorsInitializer = {};
|
|
|
|
|
|
|
|
|
2020-06-25 16:05:36 -07:00
|
|
|
export interface BrowserTypeChannel extends Channel {
|
2020-07-14 18:26:50 -07:00
|
|
|
connect(params: types.ConnectOptions): Promise<{ browser: BrowserChannel }>;
|
|
|
|
launch(params: types.LaunchOptions): Promise<{ browser: BrowserChannel }>;
|
|
|
|
launchServer(params: types.LaunchServerOptions): Promise<{ server: BrowserServerChannel }>;
|
|
|
|
launchPersistentContext(params: { userDataDir: string } & types.LaunchOptions & types.BrowserContextOptions): Promise<{ context: BrowserContextChannel }>;
|
2020-06-25 16:05:36 -07:00
|
|
|
}
|
2020-06-26 12:28:27 -07:00
|
|
|
export type BrowserTypeInitializer = {
|
|
|
|
executablePath: string,
|
|
|
|
name: string
|
|
|
|
};
|
2020-06-25 16:05:36 -07:00
|
|
|
|
2020-06-26 17:24:21 -07:00
|
|
|
|
2020-06-30 10:55:11 -07:00
|
|
|
export interface BrowserServerChannel extends Channel {
|
|
|
|
on(event: 'close', callback: () => void): this;
|
|
|
|
|
|
|
|
close(): Promise<void>;
|
|
|
|
kill(): Promise<void>;
|
|
|
|
}
|
|
|
|
export type BrowserServerInitializer = {
|
|
|
|
wsEndpoint: string,
|
|
|
|
pid: number
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-06-25 16:05:36 -07:00
|
|
|
export interface BrowserChannel extends Channel {
|
2020-06-30 10:55:11 -07:00
|
|
|
on(event: 'close', callback: () => void): this;
|
|
|
|
|
2020-06-26 11:51:47 -07:00
|
|
|
close(): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
newContext(params: types.BrowserContextOptions): Promise<{ context: BrowserContextChannel }>;
|
2020-07-07 18:47:00 -07:00
|
|
|
|
2020-07-14 18:26:50 -07:00
|
|
|
crNewBrowserCDPSession(): Promise<{ session: CDPSessionChannel }>;
|
2020-07-09 15:33:01 -07:00
|
|
|
crStartTracing(params: { page?: PageChannel, path?: string, screenshots?: boolean, categories?: string[] }): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
crStopTracing(): Promise<{ binary: Binary }>;
|
2020-06-25 16:05:36 -07:00
|
|
|
}
|
2020-06-26 12:28:27 -07:00
|
|
|
export type BrowserInitializer = {};
|
2020-06-25 16:05:36 -07:00
|
|
|
|
2020-06-26 17:24:21 -07:00
|
|
|
|
2020-06-25 16:05:36 -07:00
|
|
|
export interface BrowserContextChannel extends Channel {
|
2020-07-14 18:26:50 -07:00
|
|
|
on(event: 'bindingCall', callback: (params: { binding: BindingCallChannel }) => void): this;
|
2020-06-30 10:55:11 -07:00
|
|
|
on(event: 'close', callback: () => void): this;
|
2020-07-14 18:26:50 -07:00
|
|
|
on(event: 'page', callback: (params: { page: PageChannel }) => void): this;
|
2020-06-30 10:55:11 -07:00
|
|
|
on(event: 'route', callback: (params: { route: RouteChannel, request: RequestChannel }) => void): this;
|
|
|
|
|
2020-06-25 16:05:36 -07:00
|
|
|
addCookies(params: { cookies: types.SetNetworkCookieParam[] }): Promise<void>;
|
2020-06-26 11:51:47 -07:00
|
|
|
addInitScript(params: { source: string }): Promise<void>;
|
2020-06-25 16:05:36 -07:00
|
|
|
clearCookies(): Promise<void>;
|
|
|
|
clearPermissions(): Promise<void>;
|
2020-06-26 11:51:47 -07:00
|
|
|
close(): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
cookies(params: { urls: string[] }): Promise<{ cookies: types.NetworkCookie[] }>;
|
2020-06-26 11:51:47 -07:00
|
|
|
exposeBinding(params: { name: string }): Promise<void>;
|
2020-07-06 10:04:09 -07:00
|
|
|
grantPermissions(params: { permissions: string[], origin?: string }): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
newPage(): Promise<{ page: PageChannel }>;
|
2020-06-26 11:51:47 -07:00
|
|
|
setDefaultNavigationTimeoutNoReply(params: { timeout: number }): void;
|
|
|
|
setDefaultTimeoutNoReply(params: { timeout: number }): void;
|
2020-07-15 13:21:21 -07:00
|
|
|
setExtraHTTPHeaders(params: { headers: types.HeadersArray }): Promise<void>;
|
2020-06-26 11:51:47 -07:00
|
|
|
setGeolocation(params: { geolocation: types.Geolocation | null }): Promise<void>;
|
2020-06-25 16:05:36 -07:00
|
|
|
setHTTPCredentials(params: { httpCredentials: types.Credentials | null }): Promise<void>;
|
|
|
|
setNetworkInterceptionEnabled(params: { enabled: boolean }): Promise<void>;
|
2020-06-26 11:51:47 -07:00
|
|
|
setOffline(params: { offline: boolean }): Promise<void>;
|
2020-07-08 21:36:03 -07:00
|
|
|
|
2020-07-14 18:26:50 -07:00
|
|
|
on(event: 'crBackgroundPage', callback: (params: { page: PageChannel }) => void): this;
|
|
|
|
on(event: 'crServiceWorker', callback: (params: { worker: WorkerChannel }) => void): this;
|
|
|
|
crNewCDPSession(params: { page: PageChannel }): Promise<{ session: CDPSessionChannel }>;
|
2020-06-25 16:05:36 -07:00
|
|
|
}
|
2020-07-13 15:26:09 -07:00
|
|
|
export type BrowserContextInitializer = {};
|
2020-06-26 17:24:21 -07:00
|
|
|
|
2020-06-25 16:05:36 -07:00
|
|
|
|
|
|
|
export interface PageChannel extends Channel {
|
2020-07-14 18:26:50 -07:00
|
|
|
on(event: 'bindingCall', callback: (params: { binding: BindingCallChannel }) => void): this;
|
2020-06-26 11:51:47 -07:00
|
|
|
on(event: 'close', callback: () => void): this;
|
2020-07-14 18:26:50 -07:00
|
|
|
on(event: 'console', callback: (params: { message: ConsoleMessageChannel }) => void): this;
|
2020-06-26 21:22:03 -07:00
|
|
|
on(event: 'crash', callback: () => void): this;
|
2020-07-14 18:26:50 -07:00
|
|
|
on(event: 'dialog', callback: (params: { dialog: DialogChannel }) => void): this;
|
|
|
|
on(event: 'download', callback: (params: { download: DownloadChannel }) => void): this;
|
2020-06-26 21:22:03 -07:00
|
|
|
on(event: 'domcontentloaded', callback: () => void): this;
|
2020-06-30 10:55:11 -07:00
|
|
|
on(event: 'fileChooser', callback: (params: { element: ElementHandleChannel, isMultiple: boolean }) => void): this;
|
2020-07-14 18:26:50 -07:00
|
|
|
on(event: 'frameAttached', callback: (params: { frame: FrameChannel }) => void): this;
|
|
|
|
on(event: 'frameDetached', callback: (params: { frame: FrameChannel }) => void): this;
|
2020-06-26 21:22:03 -07:00
|
|
|
on(event: 'load', callback: () => void): this;
|
2020-06-26 11:51:47 -07:00
|
|
|
on(event: 'pageError', callback: (params: { error: types.Error }) => void): this;
|
2020-07-14 18:26:50 -07:00
|
|
|
on(event: 'popup', callback: (params: { page: PageChannel }) => void): this;
|
|
|
|
on(event: 'request', callback: (params: { request: RequestChannel }) => void): this;
|
2020-06-26 11:51:47 -07:00
|
|
|
on(event: 'requestFailed', callback: (params: { request: RequestChannel, failureText: string | null }) => void): this;
|
2020-07-14 18:26:50 -07:00
|
|
|
on(event: 'requestFinished', callback: (params: { request: RequestChannel }) => void): this;
|
|
|
|
on(event: 'response', callback: (params: { response: ResponseChannel }) => void): this;
|
2020-06-26 11:51:47 -07:00
|
|
|
on(event: 'route', callback: (params: { route: RouteChannel, request: RequestChannel }) => void): this;
|
2020-07-14 18:26:50 -07:00
|
|
|
on(event: 'worker', callback: (params: { worker: WorkerChannel }) => void): this;
|
2020-06-25 16:05:36 -07:00
|
|
|
|
|
|
|
setDefaultNavigationTimeoutNoReply(params: { timeout: number }): void;
|
|
|
|
setDefaultTimeoutNoReply(params: { timeout: number }): Promise<void>;
|
|
|
|
setFileChooserInterceptedNoReply(params: { intercepted: boolean }): Promise<void>;
|
|
|
|
|
2020-06-26 11:51:47 -07:00
|
|
|
addInitScript(params: { source: string }): Promise<void>;
|
2020-07-06 10:04:09 -07:00
|
|
|
close(params: { runBeforeUnload?: boolean }): Promise<void>;
|
|
|
|
emulateMedia(params: { media?: 'screen' | 'print', colorScheme?: 'dark' | 'light' | 'no-preference' }): Promise<void>;
|
2020-06-25 16:05:36 -07:00
|
|
|
exposeBinding(params: { name: string }): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
goBack(params: types.NavigateOptions): Promise<{ response: ResponseChannel | null }>;
|
|
|
|
goForward(params: types.NavigateOptions): Promise<{ response: ResponseChannel | null }>;
|
|
|
|
opener(): Promise<{ page: PageChannel | null }>;
|
|
|
|
reload(params: types.NavigateOptions): Promise<{ response: ResponseChannel | null }>;
|
|
|
|
screenshot(params: types.ScreenshotOptions): Promise<{ binary: Binary }>;
|
2020-07-15 13:21:21 -07:00
|
|
|
setExtraHTTPHeaders(params: { headers: types.HeadersArray }): Promise<void>;
|
2020-06-26 11:51:47 -07:00
|
|
|
setNetworkInterceptionEnabled(params: { enabled: boolean }): Promise<void>;
|
|
|
|
setViewportSize(params: { viewportSize: types.Size }): Promise<void>;
|
2020-06-25 18:01:18 -07:00
|
|
|
|
|
|
|
// Input
|
|
|
|
keyboardDown(params: { key: string }): Promise<void>;
|
|
|
|
keyboardUp(params: { key: string }): Promise<void>;
|
|
|
|
keyboardInsertText(params: { text: string }): Promise<void>;
|
2020-07-06 10:04:09 -07:00
|
|
|
keyboardType(params: { text: string, delay?: number }): Promise<void>;
|
|
|
|
keyboardPress(params: { key: string, delay?: number }): Promise<void>;
|
|
|
|
mouseMove(params: { x: number, y: number, steps?: number }): Promise<void>;
|
|
|
|
mouseDown(params: { button?: types.MouseButton, clickCount?: number }): Promise<void>;
|
|
|
|
mouseUp(params: { button?: types.MouseButton, clickCount?: number }): Promise<void>;
|
|
|
|
mouseClick(params: { x: number, y: number, delay?: number, button?: types.MouseButton, clickCount?: number }): Promise<void>;
|
2020-06-25 18:01:18 -07:00
|
|
|
|
2020-07-14 18:26:50 -07:00
|
|
|
accessibilitySnapshot(params: { interestingOnly?: boolean, root?: ElementHandleChannel }): Promise<{ rootAXNode: types.SerializedAXNode | null }>;
|
|
|
|
pdf: (params: PDFOptions) => Promise<{ pdf: Binary }>;
|
2020-07-09 15:33:01 -07:00
|
|
|
|
|
|
|
crStartJSCoverage(params: types.JSCoverageOptions): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
crStopJSCoverage(): Promise<{ entries: types.JSCoverageEntry[] }>;
|
2020-07-09 15:33:01 -07:00
|
|
|
crStartCSSCoverage(params: types.CSSCoverageOptions): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
crStopCSSCoverage(): Promise<{ entries: types.CSSCoverageEntry[] }>;
|
2020-06-25 16:05:36 -07:00
|
|
|
}
|
2020-06-30 10:55:11 -07:00
|
|
|
|
2020-06-26 12:28:27 -07:00
|
|
|
export type PageInitializer = {
|
|
|
|
mainFrame: FrameChannel,
|
2020-07-10 13:15:39 -07:00
|
|
|
viewportSize: types.Size | null,
|
|
|
|
isClosed: boolean
|
2020-06-26 12:28:27 -07:00
|
|
|
};
|
2020-06-25 16:05:36 -07:00
|
|
|
|
2020-07-15 18:48:19 -07:00
|
|
|
export type FrameNavigatedEvent = { url: string, name: string, newDocument?: { request?: RequestChannel }, error?: string };
|
|
|
|
|
2020-06-25 16:05:36 -07:00
|
|
|
export interface FrameChannel extends Channel {
|
2020-07-13 16:03:24 -07:00
|
|
|
on(event: 'loadstate', callback: (params: { add?: types.LifecycleEvent, remove?: types.LifecycleEvent }) => void): this;
|
2020-07-15 18:48:19 -07:00
|
|
|
on(event: 'navigated', callback: (params: FrameNavigatedEvent) => void): this;
|
2020-07-13 16:03:24 -07:00
|
|
|
|
2020-07-15 14:04:39 -07:00
|
|
|
evalOnSelector(params: { selector: string; expression: string, isFunction: boolean, arg: any}): Promise<{ value: any }>;
|
|
|
|
evalOnSelectorAll(params: { selector: string; expression: string, isFunction: boolean, arg: any}): Promise<{ value: any }>;
|
|
|
|
addScriptTag(params: { url?: string, content?: string, type?: string }): Promise<{ element: ElementHandleChannel }>;
|
|
|
|
addStyleTag(params: { url?: string, content?: string }): Promise<{ element: ElementHandleChannel }>;
|
|
|
|
check(params: { selector: string, force?: boolean, noWaitAfter?: boolean } & types.TimeoutOptions): Promise<void>;
|
|
|
|
click(params: { selector: string, force?: boolean, noWaitAfter?: boolean } & types.PointerActionOptions & types.MouseClickOptions & types.TimeoutOptions): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
content(): Promise<{ value: string }>;
|
2020-07-15 14:04:39 -07:00
|
|
|
dblclick(params: { selector: string, force?: boolean } & types.PointerActionOptions & types.MouseMultiClickOptions & types.TimeoutOptions): Promise<void>;
|
|
|
|
dispatchEvent(params: { selector: string, type: string, eventInit: any } & types.TimeoutOptions): Promise<void>;
|
|
|
|
evaluateExpression(params: { expression: string, isFunction: boolean, arg: any}): Promise<{ value: any }>;
|
|
|
|
evaluateExpressionHandle(params: { expression: string, isFunction: boolean, arg: any}): Promise<{ handle: JSHandleChannel }>;
|
|
|
|
fill(params: { selector: string, value: string } & types.NavigatingActionWaitOptions): Promise<void>;
|
|
|
|
focus(params: { selector: string } & types.TimeoutOptions): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
frameElement(): Promise<{ element: ElementHandleChannel }>;
|
2020-07-15 14:04:39 -07:00
|
|
|
getAttribute(params: { selector: string, name: string } & types.TimeoutOptions): Promise<{ value: string | null }>;
|
|
|
|
goto(params: { url: string } & types.GotoOptions): Promise<{ response: ResponseChannel | null }>;
|
|
|
|
hover(params: { selector: string, force?: boolean } & types.PointerActionOptions & types.TimeoutOptions): Promise<void>;
|
|
|
|
innerHTML(params: { selector: string } & types.TimeoutOptions): Promise<{ value: string }>;
|
|
|
|
innerText(params: { selector: string } & types.TimeoutOptions): Promise<{ value: string }>;
|
|
|
|
press(params: { selector: string, key: string, delay?: number, noWaitAfter?: boolean } & types.TimeoutOptions): Promise<void>;
|
|
|
|
querySelector(params: { selector: string}): Promise<{ element: ElementHandleChannel | null }>;
|
|
|
|
querySelectorAll(params: { selector: string}): Promise<{ elements: ElementHandleChannel[] }>;
|
|
|
|
selectOption(params: { selector: string, elements?: ElementHandleChannel[], options?: types.SelectOption[] } & types.NavigatingActionWaitOptions): Promise<{ values: string[] }>;
|
|
|
|
setContent(params: { html: string } & types.NavigateOptions): Promise<void>;
|
|
|
|
setInputFiles(params: { selector: string, files: { name: string, mimeType: string, buffer: Binary }[] } & types.NavigatingActionWaitOptions): Promise<void>;
|
|
|
|
textContent(params: { selector: string } & types.TimeoutOptions): Promise<{ value: string | null }>;
|
2020-07-14 18:26:50 -07:00
|
|
|
title(): Promise<{ value: string }>;
|
2020-07-15 14:04:39 -07:00
|
|
|
type(params: { selector: string, text: string, delay?: number, noWaitAfter?: boolean } & types.TimeoutOptions): Promise<void>;
|
|
|
|
uncheck(params: { selector: string, force?: boolean, noWaitAfter?: boolean } & types.TimeoutOptions): Promise<void>;
|
|
|
|
waitForFunction(params: { expression: string, isFunction: boolean, arg: any } & types.WaitForFunctionOptions): Promise<{ handle: JSHandleChannel }>;
|
|
|
|
waitForSelector(params: { selector: string } & types.WaitForElementOptions): Promise<{ element: ElementHandleChannel | null }>;
|
2020-06-25 16:05:36 -07:00
|
|
|
}
|
2020-06-26 12:28:27 -07:00
|
|
|
export type FrameInitializer = {
|
|
|
|
url: string,
|
|
|
|
name: string,
|
2020-07-13 16:03:24 -07:00
|
|
|
parentFrame: FrameChannel | null,
|
|
|
|
loadStates: types.LifecycleEvent[],
|
2020-06-26 12:28:27 -07:00
|
|
|
};
|
2020-06-25 16:05:36 -07:00
|
|
|
|
2020-06-26 17:24:21 -07:00
|
|
|
|
2020-06-30 10:55:11 -07:00
|
|
|
export interface WorkerChannel extends Channel {
|
2020-07-14 18:26:50 -07:00
|
|
|
evaluateExpression(params: { expression: string, isFunction: boolean, arg: any }): Promise<{ value: any }>;
|
|
|
|
evaluateExpressionHandle(params: { expression: string, isFunction: boolean, arg: any }): Promise<{ handle: JSHandleChannel }>;
|
2020-06-30 10:55:11 -07:00
|
|
|
}
|
|
|
|
export type WorkerInitializer = {
|
|
|
|
url: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-06-25 16:05:36 -07:00
|
|
|
export interface JSHandleChannel extends Channel {
|
2020-07-14 18:26:50 -07:00
|
|
|
on(event: 'previewUpdated', callback: (params: { preview: string }) => void): this;
|
2020-06-30 10:55:11 -07:00
|
|
|
|
2020-06-26 11:51:47 -07:00
|
|
|
dispose(): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
evaluateExpression(params: { expression: string, isFunction: boolean, arg: any }): Promise<{ value: any }>;
|
|
|
|
evaluateExpressionHandle(params: { expression: string, isFunction: boolean, arg: any}): Promise<{ handle: JSHandleChannel }>;
|
|
|
|
getPropertyList(): Promise<{ properties: { name: string, value: JSHandleChannel}[] }>;
|
|
|
|
getProperty(params: { name: string }): Promise<{ handle: JSHandleChannel }>;
|
|
|
|
jsonValue(): Promise<{ value: any }>;
|
2020-06-25 16:05:36 -07:00
|
|
|
}
|
2020-06-26 12:28:27 -07:00
|
|
|
export type JSHandleInitializer = {
|
|
|
|
preview: string,
|
|
|
|
};
|
2020-06-25 16:05:36 -07:00
|
|
|
|
2020-06-26 17:24:21 -07:00
|
|
|
|
2020-06-25 16:05:36 -07:00
|
|
|
export interface ElementHandleChannel extends JSHandleChannel {
|
2020-07-14 18:26:50 -07:00
|
|
|
evalOnSelector(params: { selector: string; expression: string, isFunction: boolean, arg: any }): Promise<{ value: any }>;
|
|
|
|
evalOnSelectorAll(params: { selector: string; expression: string, isFunction: boolean, arg: any }): Promise<{ value: any }>;
|
|
|
|
boundingBox(): Promise<{ value: types.Rect | null }>;
|
2020-07-06 10:04:09 -07:00
|
|
|
check(params: { force?: boolean } & { noWaitAfter?: boolean } & types.TimeoutOptions): Promise<void>;
|
|
|
|
click(params: { force?: boolean, noWaitAfter?: boolean } & types.PointerActionOptions & types.MouseClickOptions & types.TimeoutOptions): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
contentFrame(): Promise<{ frame: FrameChannel | null }>;
|
2020-07-06 10:04:09 -07:00
|
|
|
dblclick(params: { force?: boolean, noWaitAfter?: boolean } & types.PointerActionOptions & types.MouseMultiClickOptions & types.TimeoutOptions): Promise<void>;
|
2020-06-26 11:51:47 -07:00
|
|
|
dispatchEvent(params: { type: string, eventInit: any }): Promise<void>;
|
2020-07-06 10:04:09 -07:00
|
|
|
fill(params: { value: string } & types.NavigatingActionWaitOptions): Promise<void>;
|
2020-06-25 16:05:36 -07:00
|
|
|
focus(): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
getAttribute(params: { name: string }): Promise<{ value: string | null }>;
|
2020-07-06 10:04:09 -07:00
|
|
|
hover(params: { force?: boolean } & types.PointerActionOptions & types.TimeoutOptions): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
innerHTML(): Promise<{ value: string }>;
|
|
|
|
innerText(): Promise<{ value: string }>;
|
|
|
|
ownerFrame(): Promise<{ frame: FrameChannel | null }>;
|
2020-07-06 10:04:09 -07:00
|
|
|
press(params: { key: string, delay?: number } & types.TimeoutOptions & { noWaitAfter?: boolean }): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
querySelector(params: { selector: string }): Promise<{ element: ElementHandleChannel | null }>;
|
|
|
|
querySelectorAll(params: { selector: string }): Promise<{ elements: ElementHandleChannel[] }>;
|
|
|
|
screenshot(params: types.ElementScreenshotOptions): Promise<{ binary: Binary }>;
|
2020-07-06 10:04:09 -07:00
|
|
|
scrollIntoViewIfNeeded(params: types.TimeoutOptions): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
selectOption(params: { elements?: ElementHandleChannel[], options?: types.SelectOption[] } & types.NavigatingActionWaitOptions): Promise<{ values: string[] }>;
|
2020-07-06 10:04:09 -07:00
|
|
|
selectText(params: types.TimeoutOptions): Promise<void>;
|
2020-07-10 15:39:11 -07:00
|
|
|
setInputFiles(params: { files: { name: string, mimeType: string, buffer: Binary }[] } & types.NavigatingActionWaitOptions): Promise<void>;
|
2020-07-14 18:26:50 -07:00
|
|
|
textContent(): Promise<{ value: string | null }>;
|
2020-07-06 10:04:09 -07:00
|
|
|
type(params: { text: string, delay?: number, noWaitAfter?: boolean } & types.TimeoutOptions): Promise<void>;
|
|
|
|
uncheck(params: { force?: boolean, noWaitAfter?: boolean } & types.TimeoutOptions): Promise<void>;
|
2020-06-25 16:05:36 -07:00
|
|
|
}
|
|
|
|
|
2020-06-26 17:24:21 -07:00
|
|
|
|
2020-06-25 16:05:36 -07:00
|
|
|
export interface RequestChannel extends Channel {
|
2020-07-14 18:26:50 -07:00
|
|
|
response(): Promise<{ response: ResponseChannel | null }>;
|
2020-06-26 11:51:47 -07:00
|
|
|
}
|
2020-06-26 12:28:27 -07:00
|
|
|
export type RequestInitializer = {
|
|
|
|
frame: FrameChannel,
|
|
|
|
url: string,
|
|
|
|
resourceType: string,
|
|
|
|
method: string,
|
|
|
|
postData: string | null,
|
2020-07-15 13:21:21 -07:00
|
|
|
headers: types.HeadersArray,
|
2020-06-26 12:28:27 -07:00
|
|
|
isNavigationRequest: boolean,
|
|
|
|
redirectedFrom: RequestChannel | null,
|
|
|
|
};
|
2020-06-26 11:51:47 -07:00
|
|
|
|
2020-06-26 17:24:21 -07:00
|
|
|
|
2020-06-26 11:51:47 -07:00
|
|
|
export interface RouteChannel extends Channel {
|
|
|
|
abort(params: { errorCode: string }): Promise<void>;
|
2020-07-15 13:21:21 -07:00
|
|
|
continue(params: types.NormalizedContinueOverrides): Promise<void>;
|
|
|
|
fulfill(params: types.NormalizedFulfillResponse): Promise<void>;
|
2020-06-25 16:05:36 -07:00
|
|
|
}
|
2020-06-26 12:28:27 -07:00
|
|
|
export type RouteInitializer = {
|
|
|
|
request: RequestChannel,
|
|
|
|
};
|
2020-06-25 16:05:36 -07:00
|
|
|
|
2020-06-26 17:24:21 -07:00
|
|
|
|
2020-06-25 16:05:36 -07:00
|
|
|
export interface ResponseChannel extends Channel {
|
2020-07-14 18:26:50 -07:00
|
|
|
body(): Promise<{ binary: Binary }>;
|
|
|
|
finished(): Promise<{ error: Error | null }>;
|
2020-06-25 16:05:36 -07:00
|
|
|
}
|
2020-06-26 12:28:27 -07:00
|
|
|
export type ResponseInitializer = {
|
|
|
|
request: RequestChannel,
|
|
|
|
url: string,
|
|
|
|
status: number,
|
|
|
|
statusText: string,
|
2020-07-15 13:21:21 -07:00
|
|
|
headers: types.HeadersArray,
|
2020-06-26 12:28:27 -07:00
|
|
|
};
|
2020-06-25 16:05:36 -07:00
|
|
|
|
2020-06-26 17:24:21 -07:00
|
|
|
|
2020-06-25 18:01:18 -07:00
|
|
|
export interface ConsoleMessageChannel extends Channel {
|
|
|
|
}
|
2020-06-26 12:28:27 -07:00
|
|
|
export type ConsoleMessageInitializer = {
|
|
|
|
type: string,
|
|
|
|
text: string,
|
|
|
|
args: JSHandleChannel[],
|
|
|
|
location: types.ConsoleMessageLocation,
|
|
|
|
};
|
2020-06-26 11:51:47 -07:00
|
|
|
|
2020-06-26 17:24:21 -07:00
|
|
|
|
2020-06-26 11:51:47 -07:00
|
|
|
export interface BindingCallChannel extends Channel {
|
|
|
|
reject(params: { error: types.Error }): void;
|
|
|
|
resolve(params: { result: any }): void;
|
|
|
|
}
|
2020-06-26 12:28:27 -07:00
|
|
|
export type BindingCallInitializer = {
|
|
|
|
frame: FrameChannel,
|
|
|
|
name: string,
|
|
|
|
args: any[]
|
|
|
|
};
|
2020-06-26 17:24:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
export interface DialogChannel extends Channel {
|
|
|
|
accept(params: { promptText?: string }): Promise<void>;
|
|
|
|
dismiss(): Promise<void>;
|
|
|
|
}
|
|
|
|
export type DialogInitializer = {
|
|
|
|
type: string,
|
|
|
|
message: string,
|
|
|
|
defaultValue: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export interface DownloadChannel extends Channel {
|
2020-07-14 18:26:50 -07:00
|
|
|
path(): Promise<{ value: string | null }>;
|
|
|
|
failure(): Promise<{ error: string | null }>;
|
|
|
|
stream(): Promise<{ stream: StreamChannel | null }>;
|
2020-06-26 17:24:21 -07:00
|
|
|
delete(): Promise<void>;
|
|
|
|
}
|
|
|
|
export type DownloadInitializer = {
|
|
|
|
url: string,
|
|
|
|
suggestedFilename: string,
|
|
|
|
};
|
2020-07-07 18:47:00 -07:00
|
|
|
|
|
|
|
|
2020-07-14 10:51:37 -07:00
|
|
|
export interface StreamChannel extends Channel {
|
2020-07-14 18:26:50 -07:00
|
|
|
read(params: { size?: number }): Promise<{ binary: Binary }>;
|
2020-07-14 10:51:37 -07:00
|
|
|
}
|
|
|
|
export type StreamInitializer = {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-07 18:47:00 -07:00
|
|
|
// Chromium-specific.
|
|
|
|
export interface CDPSessionChannel extends Channel {
|
|
|
|
on(event: 'event', callback: (params: { method: string, params?: Object }) => void): this;
|
|
|
|
on(event: 'disconnected', callback: () => void): this;
|
|
|
|
|
2020-07-14 18:26:50 -07:00
|
|
|
send(params: { method: string, params?: Object }): Promise<{ result: Object }>;
|
2020-07-07 18:47:00 -07:00
|
|
|
detach(): Promise<void>;
|
|
|
|
}
|
|
|
|
export type CDPSessionInitializer = {};
|
2020-07-10 15:39:11 -07:00
|
|
|
|
|
|
|
export type PDFOptions = {
|
|
|
|
scale?: number,
|
|
|
|
displayHeaderFooter?: boolean,
|
|
|
|
headerTemplate?: string,
|
|
|
|
footerTemplate?: string,
|
|
|
|
printBackground?: boolean,
|
|
|
|
landscape?: boolean,
|
|
|
|
pageRanges?: string,
|
|
|
|
format?: string,
|
|
|
|
width?: string,
|
|
|
|
height?: string,
|
|
|
|
preferCSSPageSize?: boolean,
|
|
|
|
margin?: {top?: string, bottom?: string, left?: string, right?: string},
|
2020-07-13 21:46:59 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export type ElectronLaunchOptions = {
|
|
|
|
args?: string[],
|
|
|
|
cwd?: string,
|
|
|
|
env?: {[key: string]: string|number|boolean},
|
|
|
|
handleSIGINT?: boolean,
|
|
|
|
handleSIGTERM?: boolean,
|
|
|
|
handleSIGHUP?: boolean,
|
|
|
|
timeout?: number,
|
|
|
|
};
|
|
|
|
export interface ElectronChannel extends Channel {
|
2020-07-14 18:26:50 -07:00
|
|
|
launch(params: { executablePath: string } & ElectronLaunchOptions): Promise<{ electronApplication: ElectronApplicationChannel }>;
|
2020-07-10 15:39:11 -07:00
|
|
|
}
|
2020-07-13 21:46:59 -07:00
|
|
|
export type ElectronInitializer = {};
|
|
|
|
|
|
|
|
|
|
|
|
export interface ElectronApplicationChannel extends Channel {
|
|
|
|
on(event: 'close', callback: () => void): this;
|
2020-07-15 18:48:19 -07:00
|
|
|
on(event: 'window', callback: (params: { page: PageChannel, browserWindow: JSHandleChannel }) => void): this;
|
2020-07-13 21:46:59 -07:00
|
|
|
|
2020-07-14 18:26:50 -07:00
|
|
|
newBrowserWindow(params: { arg: any }): Promise<{ page: PageChannel }>;
|
|
|
|
evaluateExpression(params: { expression: string, isFunction: boolean, arg: any }): Promise<{ value: any }>;
|
|
|
|
evaluateExpressionHandle(params: { expression: string, isFunction: boolean, arg: any }): Promise<{ handle: JSHandleChannel }>;
|
2020-07-13 21:46:59 -07:00
|
|
|
close(): Promise<void>;
|
|
|
|
}
|
|
|
|
export type ElectronApplicationInitializer = {
|
|
|
|
context: BrowserContextChannel,
|
|
|
|
};
|