@sqaitech/android 0.30.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/bin/yadb +0 -0
- package/dist/es/index.mjs +996 -0
- package/dist/lib/index.js +1057 -0
- package/dist/types/index.d.ts +145 -0
- package/package.json +53 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { AbstractInterface } from '@sqaitech/core/device';
|
|
2
|
+
import { ADB } from 'appium-adb';
|
|
3
|
+
import { Agent } from '@sqaitech/core/agent';
|
|
4
|
+
import { AgentOpt } from '@sqaitech/core/agent';
|
|
5
|
+
import { Device } from 'appium-adb';
|
|
6
|
+
import { DeviceAction } from '@sqaitech/core';
|
|
7
|
+
import type { ElementInfo } from '@sqaitech/shared/extractor';
|
|
8
|
+
import { InterfaceType } from '@sqaitech/core';
|
|
9
|
+
import { overrideAIConfig } from '@sqaitech/shared/env';
|
|
10
|
+
import { Point } from '@sqaitech/core';
|
|
11
|
+
import { Size } from '@sqaitech/core';
|
|
12
|
+
|
|
13
|
+
export declare function agentFromAdbDevice(deviceId?: string, opts?: AndroidAgentOpt & AndroidDeviceOpt): Promise<AndroidAgent>;
|
|
14
|
+
|
|
15
|
+
export declare class AndroidAgent extends Agent<AndroidDevice> {
|
|
16
|
+
launch(uri: string): Promise<void>;
|
|
17
|
+
runAdbShell(command: string): Promise<string>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare type AndroidAgentOpt = AgentOpt;
|
|
21
|
+
|
|
22
|
+
export declare class AndroidDevice implements AbstractInterface {
|
|
23
|
+
private deviceId;
|
|
24
|
+
private yadbPushed;
|
|
25
|
+
private devicePixelRatio;
|
|
26
|
+
private devicePixelRatioInitialized;
|
|
27
|
+
private scalingRatio;
|
|
28
|
+
private adb;
|
|
29
|
+
private connectingAdb;
|
|
30
|
+
private destroyed;
|
|
31
|
+
private description;
|
|
32
|
+
private customActions?;
|
|
33
|
+
private cachedScreenSize;
|
|
34
|
+
private cachedOrientation;
|
|
35
|
+
interfaceType: InterfaceType;
|
|
36
|
+
uri: string | undefined;
|
|
37
|
+
options?: AndroidDeviceOpt;
|
|
38
|
+
actionSpace(): DeviceAction<any>[];
|
|
39
|
+
constructor(deviceId: string, options?: AndroidDeviceOpt);
|
|
40
|
+
describe(): string;
|
|
41
|
+
connect(): Promise<ADB>;
|
|
42
|
+
getAdb(): Promise<ADB>;
|
|
43
|
+
private createAdbProxy;
|
|
44
|
+
launch(uri: string): Promise<AndroidDevice>;
|
|
45
|
+
execYadb(keyboardContent: string): Promise<void>;
|
|
46
|
+
getElementsInfo(): Promise<ElementInfo[]>;
|
|
47
|
+
getElementsNodeTree(): Promise<any>;
|
|
48
|
+
getScreenSize(): Promise<{
|
|
49
|
+
override: string;
|
|
50
|
+
physical: string;
|
|
51
|
+
orientation: number;
|
|
52
|
+
}>;
|
|
53
|
+
private initializeDevicePixelRatio;
|
|
54
|
+
getDisplayDensity(): Promise<number>;
|
|
55
|
+
getDisplayOrientation(): Promise<number>;
|
|
56
|
+
size(): Promise<Size>;
|
|
57
|
+
private adjustCoordinates;
|
|
58
|
+
/**
|
|
59
|
+
* Calculate the end point for scroll operations based on start point, scroll delta, and screen boundaries.
|
|
60
|
+
* This method ensures that scroll operations stay within screen bounds and maintain a minimum scroll distance
|
|
61
|
+
* for effective scrolling gestures on Android devices.
|
|
62
|
+
*
|
|
63
|
+
* @param start - The starting point of the scroll gesture
|
|
64
|
+
* @param deltaX - The horizontal scroll distance (positive = scroll right, negative = scroll left)
|
|
65
|
+
* @param deltaY - The vertical scroll distance (positive = scroll down, negative = scroll up)
|
|
66
|
+
* @param maxWidth - The maximum width boundary (screen width)
|
|
67
|
+
* @param maxHeight - The maximum height boundary (screen height)
|
|
68
|
+
* @returns The calculated end point for the scroll gesture
|
|
69
|
+
*/
|
|
70
|
+
private calculateScrollEndPoint;
|
|
71
|
+
screenshotBase64(): Promise<string>;
|
|
72
|
+
clearInput(element: ElementInfo): Promise<void>;
|
|
73
|
+
forceScreenshot(path: string): Promise<void>;
|
|
74
|
+
url(): Promise<string>;
|
|
75
|
+
scrollUntilTop(startPoint?: Point): Promise<void>;
|
|
76
|
+
scrollUntilBottom(startPoint?: Point): Promise<void>;
|
|
77
|
+
scrollUntilLeft(startPoint?: Point): Promise<void>;
|
|
78
|
+
scrollUntilRight(startPoint?: Point): Promise<void>;
|
|
79
|
+
scrollUp(distance?: number, startPoint?: Point): Promise<void>;
|
|
80
|
+
scrollDown(distance?: number, startPoint?: Point): Promise<void>;
|
|
81
|
+
scrollLeft(distance?: number, startPoint?: Point): Promise<void>;
|
|
82
|
+
scrollRight(distance?: number, startPoint?: Point): Promise<void>;
|
|
83
|
+
ensureYadb(): Promise<void>;
|
|
84
|
+
keyboardType(text: string, options?: AndroidDeviceInputOpt): Promise<void>;
|
|
85
|
+
private normalizeKeyName;
|
|
86
|
+
keyboardPress(key: string): Promise<void>;
|
|
87
|
+
mouseClick(x: number, y: number): Promise<void>;
|
|
88
|
+
mouseDoubleClick(x: number, y: number): Promise<void>;
|
|
89
|
+
mouseMove(): Promise<void>;
|
|
90
|
+
mouseDrag(from: {
|
|
91
|
+
x: number;
|
|
92
|
+
y: number;
|
|
93
|
+
}, to: {
|
|
94
|
+
x: number;
|
|
95
|
+
y: number;
|
|
96
|
+
}, duration?: number): Promise<void>;
|
|
97
|
+
scroll(deltaX: number, deltaY: number, duration?: number): Promise<void>;
|
|
98
|
+
destroy(): Promise<void>;
|
|
99
|
+
back(): Promise<void>;
|
|
100
|
+
home(): Promise<void>;
|
|
101
|
+
recentApps(): Promise<void>;
|
|
102
|
+
longPress(x: number, y: number, duration?: number): Promise<void>;
|
|
103
|
+
pullDown(startPoint?: Point, distance?: number, duration?: number): Promise<void>;
|
|
104
|
+
pullDrag(from: {
|
|
105
|
+
x: number;
|
|
106
|
+
y: number;
|
|
107
|
+
}, to: {
|
|
108
|
+
x: number;
|
|
109
|
+
y: number;
|
|
110
|
+
}, duration: number): Promise<void>;
|
|
111
|
+
pullUp(startPoint?: Point, distance?: number, duration?: number): Promise<void>;
|
|
112
|
+
private getDisplayArg;
|
|
113
|
+
getPhysicalDisplayId(): Promise<string | null>;
|
|
114
|
+
hideKeyboard(options?: AndroidDeviceInputOpt, timeoutMs?: number): Promise<boolean>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
declare type AndroidDeviceInputOpt = {
|
|
118
|
+
autoDismissKeyboard?: boolean;
|
|
119
|
+
keyboardDismissStrategy?: 'esc-first' | 'back-first';
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
declare type AndroidDeviceOpt = {
|
|
123
|
+
androidAdbPath?: string;
|
|
124
|
+
remoteAdbHost?: string;
|
|
125
|
+
remoteAdbPort?: number;
|
|
126
|
+
imeStrategy?: ImeStrategy;
|
|
127
|
+
displayId?: number;
|
|
128
|
+
usePhysicalDisplayIdForScreenshot?: boolean;
|
|
129
|
+
usePhysicalDisplayIdForDisplayLookup?: boolean;
|
|
130
|
+
customActions?: DeviceAction<any>[];
|
|
131
|
+
screenshotResizeScale?: number;
|
|
132
|
+
alwaysRefreshScreenInfo?: boolean;
|
|
133
|
+
} & AndroidDeviceInputOpt;
|
|
134
|
+
|
|
135
|
+
export declare function getConnectedDevices(): Promise<Device[]>;
|
|
136
|
+
|
|
137
|
+
declare const IME_STRATEGY_ALWAYS_YADB: "always-yadb";
|
|
138
|
+
|
|
139
|
+
declare const IME_STRATEGY_YADB_FOR_NON_ASCII: "yadb-for-non-ascii";
|
|
140
|
+
|
|
141
|
+
declare type ImeStrategy = typeof IME_STRATEGY_ALWAYS_YADB | typeof IME_STRATEGY_YADB_FOR_NON_ASCII;
|
|
142
|
+
|
|
143
|
+
export { overrideAIConfig }
|
|
144
|
+
|
|
145
|
+
export { }
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sqaitech/android",
|
|
3
|
+
"version": "0.30.10",
|
|
4
|
+
"description": "Android automation library for SQAI",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Android UI automation",
|
|
7
|
+
"Android AI testing",
|
|
8
|
+
"Android automation library",
|
|
9
|
+
"Android automation tool",
|
|
10
|
+
"Android use"
|
|
11
|
+
],
|
|
12
|
+
"main": "./dist/lib/index.js",
|
|
13
|
+
"module": "./dist/es/index.mjs",
|
|
14
|
+
"types": "./dist/types/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"bin",
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/types/index.d.ts",
|
|
23
|
+
"import": "./dist/es/index.mjs",
|
|
24
|
+
"require": "./dist/lib/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"appium-adb": "12.12.1",
|
|
30
|
+
"@sqaitech/core": "0.30.10",
|
|
31
|
+
"@sqaitech/shared": "0.30.10"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@rslib/core": "^0.11.2",
|
|
35
|
+
"@types/node": "^18.0.0",
|
|
36
|
+
"dotenv": "^16.4.5",
|
|
37
|
+
"typescript": "^5.8.3",
|
|
38
|
+
"tsx": "^4.19.2",
|
|
39
|
+
"vitest": "3.0.5",
|
|
40
|
+
"@sqaitech/playground": "0.30.10"
|
|
41
|
+
},
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"scripts": {
|
|
44
|
+
"dev": "npm run build:watch",
|
|
45
|
+
"build": "rslib build",
|
|
46
|
+
"build:watch": "rslib build --watch",
|
|
47
|
+
"playground": "DEBUG=sqai:* tsx demo/playground.ts",
|
|
48
|
+
"test": "vitest --run",
|
|
49
|
+
"test:u": "vitest --run -u",
|
|
50
|
+
"test:ai": "AI_TEST_TYPE=android npm run test",
|
|
51
|
+
"test:ai:cache": "SQAI_CACHE=true AI_TEST_TYPE=android npm run test"
|
|
52
|
+
}
|
|
53
|
+
}
|