2020-01-07 03:22:35 +01: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.
|
|
|
|
|
*/
|
2019-11-26 00:06:52 +01:00
|
|
|
|
2020-06-23 23:51:06 +02:00
|
|
|
// NOTE: No imports allowed - only primitive, self-contained types are allowed here.
|
2019-11-28 01:03:51 +01:00
|
|
|
|
2019-12-11 20:26:34 +01:00
|
|
|
export type Size = { width: number, height: number };
|
2019-11-28 01:03:51 +01:00
|
|
|
export type Point = { x: number, y: number };
|
2019-12-11 20:26:34 +01:00
|
|
|
export type Rect = Size & Point;
|
2019-12-05 18:54:50 +01:00
|
|
|
export type Quad = [ Point, Point, Point, Point ];
|
2019-12-04 22:11:10 +01:00
|
|
|
|
|
|
|
|
export type TimeoutOptions = { timeout?: number };
|
2020-02-22 15:16:28 +01:00
|
|
|
|
2020-05-04 20:03:44 +02:00
|
|
|
export type WaitForElementOptions = TimeoutOptions & { state?: 'attached' | 'detached' | 'visible' | 'hidden' };
|
2019-12-04 22:11:10 +01:00
|
|
|
|
2020-04-30 06:34:14 +02:00
|
|
|
export type Polling = 'raf' | number;
|
2019-12-04 22:11:10 +01:00
|
|
|
export type WaitForFunctionOptions = TimeoutOptions & { polling?: Polling };
|
|
|
|
|
|
2020-04-21 01:52:26 +02:00
|
|
|
export type LifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle';
|
|
|
|
|
export const kLifecycleEvents: Set<LifecycleEvent> = new Set(['load', 'domcontentloaded', 'networkidle']);
|
2020-03-06 17:24:32 +01:00
|
|
|
|
|
|
|
|
export type NavigateOptions = TimeoutOptions & {
|
|
|
|
|
waitUntil?: LifecycleEvent,
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-07 01:24:21 +01:00
|
|
|
export type NavigatingActionWaitOptions = TimeoutOptions & {
|
2020-04-17 05:31:04 +02:00
|
|
|
noWaitAfter?: boolean,
|
2020-03-06 23:32:15 +01:00
|
|
|
};
|
|
|
|
|
|
2020-03-07 01:24:21 +01:00
|
|
|
export type PointerActionWaitOptions = TimeoutOptions & {
|
|
|
|
|
force?: boolean,
|
2020-03-06 23:32:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type WaitForNavigationOptions = TimeoutOptions & {
|
|
|
|
|
waitUntil?: LifecycleEvent,
|
|
|
|
|
url?: URLMatch
|
|
|
|
|
};
|
2020-03-06 17:24:32 +01:00
|
|
|
|
2020-06-24 19:16:54 +02:00
|
|
|
export type ElementScreenshotOptions = TimeoutOptions & {
|
2019-12-05 23:48:39 +01:00
|
|
|
type?: 'png' | 'jpeg',
|
|
|
|
|
path?: string,
|
|
|
|
|
quality?: number,
|
|
|
|
|
omitBackground?: boolean,
|
|
|
|
|
};
|
2019-12-06 20:33:24 +01:00
|
|
|
|
|
|
|
|
export type ScreenshotOptions = ElementScreenshotOptions & {
|
|
|
|
|
fullPage?: boolean,
|
|
|
|
|
clip?: Rect,
|
|
|
|
|
};
|
|
|
|
|
|
2020-01-07 20:55:24 +01:00
|
|
|
export type URLMatch = string | RegExp | ((url: URL) => boolean);
|
2019-12-30 23:09:54 +01:00
|
|
|
|
|
|
|
|
export type Credentials = {
|
|
|
|
|
username: string;
|
|
|
|
|
password: string;
|
2020-01-03 21:59:06 +01:00
|
|
|
};
|
2020-01-03 19:14:50 +01:00
|
|
|
|
|
|
|
|
export type Geolocation = {
|
2020-01-14 00:39:13 +01:00
|
|
|
longitude: number;
|
|
|
|
|
latitude: number;
|
|
|
|
|
accuracy?: number;
|
2020-01-03 21:59:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type SelectOption = {
|
|
|
|
|
value?: string;
|
|
|
|
|
label?: string;
|
|
|
|
|
index?: number;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type FilePayload = {
|
2020-04-16 19:25:28 +02:00
|
|
|
name: string,
|
|
|
|
|
mimeType: string,
|
|
|
|
|
buffer: Buffer,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type FileTransferPayload = {
|
2020-01-03 21:59:06 +01:00
|
|
|
name: string,
|
|
|
|
|
type: string,
|
|
|
|
|
data: string,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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 21:53:06 +01:00
|
|
|
|
|
|
|
|
export type DeviceDescriptor = {
|
|
|
|
|
userAgent: string,
|
2020-03-18 02:21:02 +01:00
|
|
|
viewport: Size,
|
|
|
|
|
deviceScaleFactor: number,
|
|
|
|
|
isMobile: boolean,
|
|
|
|
|
hasTouch: boolean
|
2020-01-07 21:53:06 +01:00
|
|
|
};
|
2020-03-18 00:04:42 +01:00
|
|
|
export type Devices = { [name: string]: DeviceDescriptor };
|
2020-01-07 22:57:37 +01:00
|
|
|
|
|
|
|
|
export type PDFOptions = {
|
|
|
|
|
scale?: number,
|
|
|
|
|
displayHeaderFooter?: boolean,
|
|
|
|
|
headerTemplate?: string,
|
|
|
|
|
footerTemplate?: string,
|
|
|
|
|
printBackground?: boolean,
|
|
|
|
|
landscape?: boolean,
|
|
|
|
|
pageRanges?: string,
|
|
|
|
|
format?: string,
|
|
|
|
|
width?: string|number,
|
|
|
|
|
height?: string|number,
|
|
|
|
|
preferCSSPageSize?: boolean,
|
|
|
|
|
margin?: {top?: string|number, bottom?: string|number, left?: string|number, right?: string|number},
|
|
|
|
|
path?: string,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type CoverageEntry = {
|
|
|
|
|
url: string,
|
|
|
|
|
text: string,
|
2020-02-07 22:36:49 +01:00
|
|
|
ranges: {start: number, end: number}[]
|
2020-01-07 22:57:37 +01:00
|
|
|
};
|
2020-01-17 02:46:50 +01:00
|
|
|
|
|
|
|
|
export type CSSCoverageOptions = {
|
|
|
|
|
resetOnNavigation?: boolean,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type JSCoverageOptions = {
|
|
|
|
|
resetOnNavigation?: boolean,
|
|
|
|
|
reportAnonymousScripts?: boolean,
|
|
|
|
|
};
|
2020-03-25 22:08:46 +01:00
|
|
|
|
2020-06-02 00:48:23 +02:00
|
|
|
export type InjectedScriptProgress = {
|
2020-06-25 00:12:17 +02:00
|
|
|
aborted: boolean,
|
2020-06-02 00:48:23 +02:00
|
|
|
log: (message: string) => void,
|
2020-06-11 03:45:18 +02:00
|
|
|
logRepeating: (message: string) => void,
|
2020-06-02 00:48:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type InjectedScriptLogs = { current: string[], next: Promise<InjectedScriptLogs> };
|
|
|
|
|
export type InjectedScriptPoll<T> = {
|
2020-05-31 00:00:53 +02:00
|
|
|
result: Promise<T>,
|
2020-06-02 00:48:23 +02:00
|
|
|
logs: Promise<InjectedScriptLogs>,
|
2020-06-07 05:59:06 +02:00
|
|
|
takeLastLogs: () => string[],
|
2020-05-31 00:00:53 +02:00
|
|
|
cancel: () => void,
|
|
|
|
|
};
|
2020-06-05 22:50:15 +02:00
|
|
|
|
|
|
|
|
export type ProxySettings = {
|
|
|
|
|
server: string,
|
|
|
|
|
bypass?: string,
|
|
|
|
|
username?: string,
|
|
|
|
|
password?: string
|
2020-06-11 00:12:50 +02:00
|
|
|
};
|
|
|
|
|
|
2020-06-23 23:51:06 +02:00
|
|
|
export type WaitForEventOptions = Function | { predicate?: Function, timeout?: number };
|
2020-06-17 02:11:19 +02:00
|
|
|
|
2020-06-23 23:51:06 +02:00
|
|
|
export type KeyboardModifier = 'Alt' | 'Control' | 'Meta' | 'Shift';
|
|
|
|
|
export type MouseButton = 'left' | 'right' | 'middle';
|
2020-06-17 02:11:19 +02:00
|
|
|
|
2020-06-23 23:51:06 +02: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;
|
|
|
|
|
};
|