2020-01-06 18:22:35 -08:00
|
|
|
/**
|
2020-06-25 18:01:18 -07:00
|
|
|
* Copyright 2018 Google Inc. All rights reserved.
|
|
|
|
* Modifications copyright (c) Microsoft Corporation.
|
2020-01-06 18:22:35 -08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2019-11-25 15:06:52 -08:00
|
|
|
|
2021-02-10 18:52:28 -08:00
|
|
|
import { Size, Point, Rect, TimeoutOptions } from '../common/types';
|
|
|
|
export { Size, Point, Rect, Quad, URLMatch, TimeoutOptions } from '../common/types';
|
2020-02-22 06:16:28 -08:00
|
|
|
|
2020-05-04 11:03:44 -07:00
|
|
|
export type WaitForElementOptions = TimeoutOptions & { state?: 'attached' | 'detached' | 'visible' | 'hidden' };
|
2019-12-04 13:11:10 -08:00
|
|
|
|
2020-08-22 07:07:13 -07:00
|
|
|
export type WaitForFunctionOptions = TimeoutOptions & { pollingInterval?: number };
|
2019-12-04 13:11:10 -08:00
|
|
|
|
2020-04-20 16:52:26 -07:00
|
|
|
export type LifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle';
|
|
|
|
export const kLifecycleEvents: Set<LifecycleEvent> = new Set(['load', 'domcontentloaded', 'networkidle']);
|
2020-03-06 08:24:32 -08:00
|
|
|
|
|
|
|
export type NavigateOptions = TimeoutOptions & {
|
|
|
|
waitUntil?: LifecycleEvent,
|
|
|
|
};
|
|
|
|
|
2020-03-06 16:24:21 -08:00
|
|
|
export type NavigatingActionWaitOptions = TimeoutOptions & {
|
2020-04-16 20:31:04 -07:00
|
|
|
noWaitAfter?: boolean,
|
2020-03-06 14:32:15 -08:00
|
|
|
};
|
|
|
|
|
2020-03-06 16:24:21 -08:00
|
|
|
export type PointerActionWaitOptions = TimeoutOptions & {
|
|
|
|
force?: boolean,
|
2020-03-06 14:32:15 -08:00
|
|
|
};
|
|
|
|
|
2020-06-24 10:16:54 -07:00
|
|
|
export type ElementScreenshotOptions = TimeoutOptions & {
|
2019-12-05 14:48:39 -08:00
|
|
|
type?: 'png' | 'jpeg',
|
|
|
|
quality?: number,
|
|
|
|
omitBackground?: boolean,
|
|
|
|
};
|
2019-12-06 11:33:24 -08:00
|
|
|
|
|
|
|
export type ScreenshotOptions = ElementScreenshotOptions & {
|
|
|
|
fullPage?: boolean,
|
|
|
|
clip?: Rect,
|
|
|
|
};
|
|
|
|
|
2020-09-04 22:37:38 -07:00
|
|
|
export type PageScreencastOptions = {
|
2020-08-10 21:22:57 -07:00
|
|
|
width: number,
|
|
|
|
height: number,
|
2020-08-19 12:45:31 -07:00
|
|
|
outputFile: string,
|
|
|
|
};
|
|
|
|
|
2019-12-30 14:09:54 -08:00
|
|
|
export type Credentials = {
|
|
|
|
username: string;
|
|
|
|
password: string;
|
2020-01-03 12:59:06 -08:00
|
|
|
};
|
2020-01-03 10:14:50 -08:00
|
|
|
|
|
|
|
export type Geolocation = {
|
2020-01-13 15:39:13 -08:00
|
|
|
longitude: number;
|
|
|
|
latitude: number;
|
|
|
|
accuracy?: number;
|
2020-01-03 12:59:06 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
export type SelectOption = {
|
|
|
|
value?: string;
|
|
|
|
label?: string;
|
|
|
|
index?: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type FilePayload = {
|
2020-04-16 10:25:28 -07:00
|
|
|
name: string,
|
|
|
|
mimeType: string,
|
2020-08-18 17:32:11 -07:00
|
|
|
buffer: string,
|
2020-01-03 12:59:06 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
export type MediaType = 'screen' | 'print';
|
|
|
|
export const mediaTypes: Set<MediaType> = new Set(['screen', 'print']);
|
|
|
|
|
|
|
|
export type ColorScheme = 'dark' | 'light' | 'no-preference';
|
|
|
|
export const colorSchemes: Set<ColorScheme> = new Set(['dark', 'light', 'no-preference']);
|
2020-01-07 12:53:06 -08:00
|
|
|
|
|
|
|
export type DeviceDescriptor = {
|
|
|
|
userAgent: string,
|
2020-03-17 18:21:02 -07:00
|
|
|
viewport: Size,
|
|
|
|
deviceScaleFactor: number,
|
|
|
|
isMobile: boolean,
|
2020-09-03 22:12:43 +02:00
|
|
|
hasTouch: boolean,
|
|
|
|
defaultBrowserType: 'chromium' | 'firefox' | 'webkit'
|
2020-01-07 12:53:06 -08:00
|
|
|
};
|
2020-03-17 16:04:42 -07:00
|
|
|
export type Devices = { [name: string]: DeviceDescriptor };
|
2020-01-07 13:57:37 -08:00
|
|
|
|
|
|
|
export type PDFOptions = {
|
|
|
|
scale?: number,
|
|
|
|
displayHeaderFooter?: boolean,
|
|
|
|
headerTemplate?: string,
|
|
|
|
footerTemplate?: string,
|
|
|
|
printBackground?: boolean,
|
|
|
|
landscape?: boolean,
|
|
|
|
pageRanges?: string,
|
|
|
|
format?: string,
|
2020-08-18 18:48:44 -07:00
|
|
|
width?: string,
|
|
|
|
height?: string,
|
2020-01-07 13:57:37 -08:00
|
|
|
preferCSSPageSize?: boolean,
|
2020-08-18 18:48:44 -07:00
|
|
|
margin?: {top?: string, bottom?: string, left?: string, right?: string},
|
2020-01-07 13:57:37 -08:00
|
|
|
}
|
|
|
|
|
2020-01-16 17:46:50 -08:00
|
|
|
export type CSSCoverageOptions = {
|
|
|
|
resetOnNavigation?: boolean,
|
|
|
|
};
|
|
|
|
|
|
|
|
export type JSCoverageOptions = {
|
|
|
|
resetOnNavigation?: boolean,
|
|
|
|
reportAnonymousScripts?: boolean,
|
|
|
|
};
|
2020-03-25 14:08:46 -07:00
|
|
|
|
2020-07-09 15:33:01 -07:00
|
|
|
export type JSRange = {
|
|
|
|
startOffset: number,
|
|
|
|
endOffset: number,
|
|
|
|
count: number
|
|
|
|
};
|
|
|
|
|
|
|
|
export type CSSCoverageEntry = {
|
|
|
|
url: string,
|
|
|
|
text?: string,
|
|
|
|
ranges: {
|
|
|
|
start: number,
|
|
|
|
end: number
|
|
|
|
}[]
|
|
|
|
};
|
|
|
|
|
|
|
|
export type JSCoverageEntry = {
|
|
|
|
url: string,
|
2020-07-17 09:02:49 +05:30
|
|
|
scriptId: string,
|
2020-07-09 15:33:01 -07:00
|
|
|
source?: string,
|
|
|
|
functions: {
|
|
|
|
functionName: string,
|
2020-07-17 09:02:49 +05:30
|
|
|
isBlockCoverage: boolean,
|
2020-07-09 15:33:01 -07:00
|
|
|
ranges: JSRange[]
|
|
|
|
}[]
|
|
|
|
};
|
|
|
|
|
2020-06-05 13:50:15 -07:00
|
|
|
export type ProxySettings = {
|
|
|
|
server: string,
|
|
|
|
bypass?: string,
|
|
|
|
username?: string,
|
|
|
|
password?: string
|
2020-06-10 15:12:50 -07:00
|
|
|
};
|
|
|
|
|
2020-06-23 14:51:06 -07:00
|
|
|
export type KeyboardModifier = 'Alt' | 'Control' | 'Meta' | 'Shift';
|
|
|
|
export type MouseButton = 'left' | 'right' | 'middle';
|
2020-06-16 17:11:19 -07:00
|
|
|
|
2020-06-23 14:51:06 -07:00
|
|
|
export type PointerActionOptions = {
|
|
|
|
modifiers?: KeyboardModifier[];
|
|
|
|
position?: Point;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type MouseClickOptions = PointerActionOptions & {
|
|
|
|
delay?: number;
|
|
|
|
button?: MouseButton;
|
|
|
|
clickCount?: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type MouseMultiClickOptions = PointerActionOptions & {
|
|
|
|
delay?: number;
|
|
|
|
button?: MouseButton;
|
|
|
|
};
|
2020-06-24 17:03:28 -07:00
|
|
|
|
|
|
|
export type World = 'main' | 'utility';
|
2020-06-25 08:30:56 -07:00
|
|
|
|
2020-07-15 13:21:21 -07:00
|
|
|
export type HeadersArray = { name: string, value: string }[];
|
2020-06-25 08:30:56 -07:00
|
|
|
|
|
|
|
export type GotoOptions = NavigateOptions & {
|
|
|
|
referer?: string,
|
|
|
|
};
|
|
|
|
|
2020-06-29 16:37:38 -07:00
|
|
|
export type NormalizedFulfillResponse = {
|
|
|
|
status: number,
|
2020-07-15 13:21:21 -07:00
|
|
|
headers: HeadersArray,
|
2020-07-03 18:04:08 -07:00
|
|
|
body: string,
|
|
|
|
isBase64: boolean,
|
2020-06-29 16:37:38 -07:00
|
|
|
};
|
|
|
|
|
2020-07-15 13:21:21 -07:00
|
|
|
export type NormalizedContinueOverrides = {
|
2020-11-16 09:59:00 -08:00
|
|
|
url?: string,
|
2020-07-15 13:21:21 -07:00
|
|
|
method?: string,
|
|
|
|
headers?: HeadersArray,
|
2020-07-24 12:16:45 -07:00
|
|
|
postData?: Buffer,
|
2020-07-15 13:21:21 -07:00
|
|
|
};
|
|
|
|
|
2020-06-25 08:30:56 -07:00
|
|
|
export type NetworkCookie = {
|
|
|
|
name: string,
|
|
|
|
value: string,
|
|
|
|
domain: string,
|
|
|
|
path: string,
|
|
|
|
expires: number,
|
|
|
|
httpOnly: boolean,
|
|
|
|
secure: boolean,
|
|
|
|
sameSite: 'Strict' | 'Lax' | 'None'
|
|
|
|
};
|
|
|
|
|
|
|
|
export type SetNetworkCookieParam = {
|
|
|
|
name: string,
|
|
|
|
value: string,
|
|
|
|
url?: string,
|
|
|
|
domain?: string,
|
|
|
|
path?: string,
|
|
|
|
expires?: number,
|
|
|
|
httpOnly?: boolean,
|
|
|
|
secure?: boolean,
|
|
|
|
sameSite?: 'Strict' | 'Lax' | 'None'
|
|
|
|
};
|
|
|
|
|
2021-03-30 05:10:58 +08:00
|
|
|
export type EmulatedSize = { viewport: Size, screen: Size };
|
|
|
|
|
2020-06-25 08:30:56 -07:00
|
|
|
export type BrowserContextOptions = {
|
2021-02-11 17:46:54 -08:00
|
|
|
sdkLanguage: string,
|
2020-08-18 09:37:40 -07:00
|
|
|
viewport?: Size,
|
2021-03-30 05:10:58 +08:00
|
|
|
screen?: Size,
|
2020-08-18 09:37:40 -07:00
|
|
|
noDefaultViewport?: boolean,
|
2020-06-25 08:30:56 -07:00
|
|
|
ignoreHTTPSErrors?: boolean,
|
|
|
|
javaScriptEnabled?: boolean,
|
|
|
|
bypassCSP?: boolean,
|
|
|
|
userAgent?: string,
|
|
|
|
locale?: string,
|
|
|
|
timezoneId?: string,
|
|
|
|
geolocation?: Geolocation,
|
|
|
|
permissions?: string[],
|
2020-08-18 15:38:29 -07:00
|
|
|
extraHTTPHeaders?: HeadersArray,
|
2020-06-25 08:30:56 -07:00
|
|
|
offline?: boolean,
|
|
|
|
httpCredentials?: Credentials,
|
|
|
|
deviceScaleFactor?: number,
|
|
|
|
isMobile?: boolean,
|
|
|
|
hasTouch?: boolean,
|
|
|
|
colorScheme?: ColorScheme,
|
|
|
|
acceptDownloads?: boolean,
|
2020-11-02 19:42:05 -08:00
|
|
|
recordVideo?: {
|
|
|
|
dir: string,
|
|
|
|
size?: Size,
|
|
|
|
},
|
2020-10-26 14:32:07 -07:00
|
|
|
recordHar?: {
|
|
|
|
omitContent?: boolean,
|
|
|
|
path: string
|
|
|
|
},
|
2020-10-29 16:12:30 -07:00
|
|
|
proxy?: ProxySettings,
|
2021-01-20 19:16:23 -08:00
|
|
|
_traceDir?: string,
|
2021-01-28 19:50:57 +01:00
|
|
|
_debugName?: string,
|
2020-06-25 08:30:56 -07:00
|
|
|
};
|
|
|
|
|
2020-07-17 09:32:27 -07:00
|
|
|
export type EnvArray = { name: string, value: string }[];
|
2020-06-25 08:30:56 -07:00
|
|
|
|
2021-03-24 04:21:03 +08:00
|
|
|
export type BrowserChannel = 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary';
|
|
|
|
|
2021-02-11 17:46:54 -08:00
|
|
|
type LaunchOptionsBase = {
|
2021-03-24 04:21:03 +08:00
|
|
|
channel?: BrowserChannel,
|
2020-06-25 08:30:56 -07:00
|
|
|
executablePath?: string,
|
|
|
|
args?: string[],
|
2020-08-18 09:37:40 -07:00
|
|
|
ignoreDefaultArgs?: string[],
|
|
|
|
ignoreAllDefaultArgs?: boolean,
|
2020-06-25 08:30:56 -07:00
|
|
|
handleSIGINT?: boolean,
|
|
|
|
handleSIGTERM?: boolean,
|
|
|
|
handleSIGHUP?: boolean,
|
|
|
|
timeout?: number,
|
2020-08-18 09:37:40 -07:00
|
|
|
env?: EnvArray,
|
2020-06-25 08:30:56 -07:00
|
|
|
headless?: boolean,
|
|
|
|
devtools?: boolean,
|
|
|
|
proxy?: ProxySettings,
|
|
|
|
downloadsPath?: string,
|
2020-07-21 13:49:09 -07:00
|
|
|
chromiumSandbox?: boolean,
|
2021-02-15 08:32:13 -08:00
|
|
|
slowMo?: number,
|
|
|
|
useWebSocket?: boolean,
|
2020-06-25 08:30:56 -07:00
|
|
|
};
|
2021-01-29 16:00:56 -08:00
|
|
|
export type LaunchOptions = LaunchOptionsBase & {
|
2020-08-18 09:37:40 -07:00
|
|
|
firefoxUserPrefs?: { [key: string]: string | number | boolean },
|
|
|
|
};
|
|
|
|
export type LaunchPersistentOptions = LaunchOptionsBase & BrowserContextOptions;
|
2020-06-25 08:30:56 -07:00
|
|
|
|
2020-11-11 15:12:10 -08:00
|
|
|
export type ProtocolLogger = (direction: 'send' | 'receive', message: object) => void;
|
|
|
|
|
2020-06-25 18:01:18 -07:00
|
|
|
export type SerializedAXNode = {
|
|
|
|
role: string,
|
|
|
|
name: string,
|
2020-08-18 20:25:03 -07:00
|
|
|
valueString?: string,
|
|
|
|
valueNumber?: number,
|
2020-06-25 18:01:18 -07:00
|
|
|
description?: string,
|
|
|
|
|
|
|
|
keyshortcuts?: string,
|
|
|
|
roledescription?: string,
|
|
|
|
valuetext?: string,
|
|
|
|
|
|
|
|
disabled?: boolean,
|
|
|
|
expanded?: boolean,
|
|
|
|
focused?: boolean,
|
|
|
|
modal?: boolean,
|
|
|
|
multiline?: boolean,
|
|
|
|
multiselectable?: boolean,
|
|
|
|
readonly?: boolean,
|
|
|
|
required?: boolean,
|
|
|
|
selected?: boolean,
|
|
|
|
|
2020-08-18 20:25:03 -07:00
|
|
|
checked?: 'checked' | 'unchecked' | 'mixed',
|
|
|
|
pressed?: 'pressed' | 'released' | 'mixed',
|
2020-06-25 18:01:18 -07:00
|
|
|
|
|
|
|
level?: number,
|
|
|
|
valuemin?: number,
|
|
|
|
valuemax?: number,
|
|
|
|
|
|
|
|
autocomplete?: string,
|
|
|
|
haspopup?: string,
|
|
|
|
invalid?: string,
|
|
|
|
orientation?: string,
|
|
|
|
|
|
|
|
children?: SerializedAXNode[]
|
|
|
|
};
|
|
|
|
|
|
|
|
export type ConsoleMessageLocation = {
|
2020-08-05 22:25:56 -07:00
|
|
|
url: string,
|
|
|
|
lineNumber: number,
|
|
|
|
columnNumber: number,
|
2020-06-25 18:01:18 -07:00
|
|
|
};
|
2020-06-26 11:51:47 -07:00
|
|
|
|
|
|
|
export type Error = {
|
2020-07-20 17:38:06 -07:00
|
|
|
message: string,
|
|
|
|
name: string,
|
2020-06-26 11:51:47 -07:00
|
|
|
stack?: string,
|
|
|
|
};
|
2020-08-18 19:13:40 -07:00
|
|
|
|
2020-11-13 14:24:53 -08:00
|
|
|
export type NameValueList = {
|
|
|
|
name: string;
|
|
|
|
value: string;
|
|
|
|
}[];
|
|
|
|
|
|
|
|
export type OriginStorage = {
|
|
|
|
origin: string;
|
|
|
|
localStorage: NameValueList;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type StorageState = {
|
|
|
|
cookies: NetworkCookie[],
|
|
|
|
origins: OriginStorage[]
|
|
|
|
}
|
|
|
|
|
|
|
|
export type SetStorageState = {
|
|
|
|
cookies?: SetNetworkCookieParam[],
|
|
|
|
origins?: OriginStorage[]
|
|
|
|
}
|