playwright/android-types-internal.d.ts

154 lines
5.5 KiB
TypeScript
Raw Normal View History

/**
* 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.
*/
2020-12-10 04:15:24 +03:00
import { EventEmitter } from 'events';
export interface AndroidDevice<BrowserContextOptions, BrowserContext, Page> extends EventEmitter {
input: AndroidInput;
setDefaultTimeout(timeout: number): void;
on(event: 'webview', handler: (webView: AndroidWebView<Page>) => void): this;
2020-12-11 03:37:18 +03:00
waitForEvent(event: string, optionsOrPredicate?: (data: any) => boolean | { timeout?: number, predicate?: (data: any) => boolean }): Promise<any>;
2020-12-10 04:15:24 +03:00
serial(): string;
model(): string;
webViews(): AndroidWebView<Page>[];
2020-12-12 10:36:08 +03:00
webView(selector: { pkg: string }, options?: { timeout?: number }): Promise<AndroidWebView<Page>>;
shell(command: string): Promise<Buffer>;
open(command: string): Promise<AndroidSocket>;
installApk(file: string | Buffer, options?: { args?: string[] }): Promise<void>;
2020-12-14 09:00:37 +03:00
push(file: string | Buffer, path: string, options?: { mode?: number }): Promise<void>;
2020-12-10 04:15:24 +03:00
launchBrowser(options?: BrowserContextOptions & { packageName?: string }): Promise<BrowserContext>;
close(): Promise<void>;
wait(selector: AndroidSelector, options?: { state?: 'gone' } & { timeout?: number }): Promise<void>;
fill(selector: AndroidSelector, text: string, options?: { timeout?: number }): Promise<void>;
press(selector: AndroidSelector, key: AndroidKey, options?: { duration?: number } & { timeout?: number }): Promise<void>;
tap(selector: AndroidSelector, options?: { duration?: number } & { timeout?: number }): Promise<void>;
drag(selector: AndroidSelector, dest: { x: number, y: number }, options?: { speed?: number } & { timeout?: number }): Promise<void>;
fling(selector: AndroidSelector, direction: 'down' | 'up' | 'left' | 'right', options?: { speed?: number } & { timeout?: number }): Promise<void>;
longTap(selector: AndroidSelector, options?: { timeout?: number }): Promise<void>;
pinchClose(selector: AndroidSelector, percent: number, options?: { speed?: number } & { timeout?: number }): Promise<void>;
pinchOpen(selector: AndroidSelector, percent: number, options?: { speed?: number } & { timeout?: number }): Promise<void>;
scroll(selector: AndroidSelector, direction: 'down' | 'up' | 'left' | 'right', percent: number, options?: { speed?: number } & { timeout?: number }): Promise<void>;
swipe(selector: AndroidSelector, direction: 'down' | 'up' | 'left' | 'right', percent: number, options?: { speed?: number } & { timeout?: number }): Promise<void>;
info(selector: AndroidSelector): Promise<AndroidElementInfo>;
}
export interface AndroidSocket extends EventEmitter {
on(event: 'data', handler: (data: Buffer) => void): this;
write(data: Buffer): Promise<void>
close(): Promise<void>
}
2020-12-10 04:15:24 +03:00
export interface AndroidInput {
type(text: string): Promise<void>;
press(key: AndroidKey): Promise<void>;
tap(point: { x: number, y: number }): Promise<void>;
swipe(from: { x: number, y: number }, segments: { x: number, y: number }[], steps: number): Promise<void>;
drag(from: { x: number, y: number }, to: { x: number, y: number }, steps: number): Promise<void>;
}
export interface AndroidWebView<Page> extends EventEmitter {
on(event: 'close', handler: () => void): this;
pid(): number;
pkg(): string;
page(): Promise<Page>;
}
export type AndroidElementInfo = {
clazz: string;
desc: string;
res: string;
pkg: string;
text: string;
bounds: { x: number, y: number, width: number, height: number };
checkable: boolean;
checked: boolean;
clickable: boolean;
enabled: boolean;
focusable: boolean;
focused: boolean;
longClickable: boolean;
scrollable: boolean;
selected: boolean;
};
export type AndroidSelector = {
checkable?: boolean,
checked?: boolean,
clazz?: string | RegExp,
clickable?: boolean,
depth?: number,
desc?: string | RegExp,
enabled?: boolean,
focusable?: boolean,
focused?: boolean,
hasChild?: { selector: AndroidSelector },
hasDescendant?: { selector: AndroidSelector, maxDepth?: number },
longClickable?: boolean,
pkg?: string | RegExp,
res?: string | RegExp,
scrollable?: boolean,
selected?: boolean,
text?: string | RegExp,
};
export type AndroidKey =
'Unknown' |
'SoftLeft' | 'SoftRight' |
'Home' |
'Back' |
'Call' | 'EndCall' |
'0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
'Star' | 'Pound' | '*' | '#' |
'DialUp' | 'DialDown' | 'DialLeft' | 'DialRight' | 'DialCenter' |
'VolumeUp' | 'VolumeDown' |
'Power' |
'Camera' |
'Clear' |
'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' |
'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' |
'Comma' | ',' |
'Period' | '.' |
'AltLeft' | 'AltRight' |
'ShiftLeft' | 'ShiftRight' |
'Tab' | '\t' |
'Space' | ' ' |
'Sym' |
'Explorer' |
'Envelop' |
'Enter' | '\n' |
'Del' |
'Grave' |
'Minus' | '-' |
'Equals' | '=' |
'LeftBracket' | '(' |
'RightBracket' | ')' |
'Backslash' | '\\' |
'Semicolon' | ';' |
'Apostrophe' | '`' |
'Slash' | '/' |
'At' |
'Num' |
'HeadsetHook' |
'Focus' |
'Plus' | '+' |
'Menu' |
'Notification' |
'Search';