assistsx-js 0.0.1353 → 0.0.2002
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/dist/AssistsX.d.ts +28 -16
- package/dist/AssistsX.js +144 -52
- package/dist/AssistsXAsync.d.ts +324 -0
- package/dist/AssistsXAsync.js +532 -0
- package/dist/CallMethod.d.ts +1 -0
- package/dist/CallMethod.js +1 -0
- package/dist/Node.d.ts +17 -8
- package/dist/Node.js +75 -20
- package/dist/NodeAsync.d.ts +200 -0
- package/dist/NodeAsync.js +308 -0
- package/dist/Step.d.ts +18 -20
- package/dist/Step.js +75 -44
- package/dist/StepAsync.d.ts +162 -0
- package/dist/StepAsync.js +264 -0
- package/dist/StepError.d.ts +27 -0
- package/dist/StepError.js +15 -0
- package/dist/Utils.d.ts +1 -0
- package/dist/Utils.js +12 -4
- package/dist/index.d.ts +13 -10
- package/dist/index.js +13 -10
- package/package.json +2 -2
- package/src/AssistsX.ts +815 -589
- package/src/AssistsXAsync.ts +723 -0
- package/src/CallMethod.ts +2 -1
- package/src/Node.ts +440 -323
- package/src/NodeAsync.ts +411 -0
- package/src/Step.ts +646 -490
- package/src/StepAsync.ts +365 -0
- package/src/StepError.ts +47 -0
- package/src/Utils.ts +16 -7
- package/src/global.d.ts +12 -9
- package/src/index.ts +13 -10
package/dist/Step.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { Node } from
|
|
1
|
+
import { Node } from "./Node";
|
|
2
|
+
import { StepAsync } from "./StepAsync";
|
|
3
|
+
export type StepResult = Step | undefined;
|
|
4
|
+
export type StepImpl = (step: Step) => Promise<StepResult>;
|
|
2
5
|
export declare class Step {
|
|
3
6
|
static delayMsDefault: number;
|
|
4
7
|
static readonly repeatCountInfinite: number;
|
|
@@ -15,17 +18,17 @@ export declare class Step {
|
|
|
15
18
|
* @param data 步骤数据
|
|
16
19
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
17
20
|
*/
|
|
18
|
-
static run(impl:
|
|
21
|
+
static run(impl: StepImpl, { tag, data, delayMs, }?: {
|
|
19
22
|
tag?: string | undefined;
|
|
20
23
|
data?: any | undefined;
|
|
21
24
|
delayMs?: number;
|
|
22
|
-
}): Promise<
|
|
25
|
+
}): Promise<Step>;
|
|
23
26
|
/**
|
|
24
27
|
* 获取当前步骤ID
|
|
25
28
|
*/
|
|
26
29
|
static get stepId(): string | undefined;
|
|
27
30
|
/**
|
|
28
|
-
* 验证步骤ID
|
|
31
|
+
* 验证步骤ID是否匹配,如果不匹配则表示停止
|
|
29
32
|
* @param stepId 要验证的步骤ID
|
|
30
33
|
*/
|
|
31
34
|
static assert(stepId: string | undefined): void;
|
|
@@ -66,7 +69,7 @@ export declare class Step {
|
|
|
66
69
|
/**
|
|
67
70
|
* 步骤实现函数
|
|
68
71
|
*/
|
|
69
|
-
impl:
|
|
72
|
+
impl: StepImpl;
|
|
70
73
|
/**
|
|
71
74
|
* 构造函数
|
|
72
75
|
* @param stepId 步骤ID
|
|
@@ -75,14 +78,15 @@ export declare class Step {
|
|
|
75
78
|
* @param data 步骤数据
|
|
76
79
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
77
80
|
*/
|
|
78
|
-
constructor({ stepId, impl, tag, data, delayMs, repeatCountMax }: {
|
|
81
|
+
constructor({ stepId, impl, tag, data, delayMs, repeatCountMax, }: {
|
|
79
82
|
stepId: string;
|
|
80
|
-
impl:
|
|
83
|
+
impl: StepImpl;
|
|
81
84
|
tag?: string | undefined;
|
|
82
85
|
data?: any | undefined;
|
|
83
86
|
delayMs?: number;
|
|
84
87
|
repeatCountMax?: number;
|
|
85
88
|
});
|
|
89
|
+
get async(): StepAsync;
|
|
86
90
|
/**
|
|
87
91
|
* 创建下一个步骤
|
|
88
92
|
* @param impl 下一步骤实现函数
|
|
@@ -91,7 +95,7 @@ export declare class Step {
|
|
|
91
95
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
92
96
|
* @returns 新的步骤实例
|
|
93
97
|
*/
|
|
94
|
-
next(impl:
|
|
98
|
+
next(impl: StepImpl, { tag, data, delayMs, repeatCountMax, }?: {
|
|
95
99
|
tag?: string | undefined;
|
|
96
100
|
data?: any | undefined;
|
|
97
101
|
delayMs?: number;
|
|
@@ -105,7 +109,7 @@ export declare class Step {
|
|
|
105
109
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
106
110
|
* @returns 当前步骤实例
|
|
107
111
|
*/
|
|
108
|
-
repeat({ stepId, tag, data, delayMs, repeatCountMax }?: {
|
|
112
|
+
repeat({ stepId, tag, data, delayMs, repeatCountMax, }?: {
|
|
109
113
|
stepId?: string;
|
|
110
114
|
tag?: string | undefined;
|
|
111
115
|
data?: any | undefined;
|
|
@@ -146,7 +150,7 @@ export declare class Step {
|
|
|
146
150
|
* @param filterText 文本过滤
|
|
147
151
|
* @returns 节点数组
|
|
148
152
|
*/
|
|
149
|
-
getAllNodes({ filterClass, filterViewId, filterDes, filterText }?: {
|
|
153
|
+
getAllNodes({ filterClass, filterViewId, filterDes, filterText, }?: {
|
|
150
154
|
filterClass?: string;
|
|
151
155
|
filterViewId?: string;
|
|
152
156
|
filterDes?: string;
|
|
@@ -171,7 +175,7 @@ export declare class Step {
|
|
|
171
175
|
* @param filterDes 描述过滤
|
|
172
176
|
* @returns 节点数组
|
|
173
177
|
*/
|
|
174
|
-
findById(id: string, { filterClass, filterText, filterDes }?: {
|
|
178
|
+
findById(id: string, { filterClass, filterText, filterDes, }?: {
|
|
175
179
|
filterClass?: string;
|
|
176
180
|
filterText?: string;
|
|
177
181
|
filterDes?: string;
|
|
@@ -184,7 +188,7 @@ export declare class Step {
|
|
|
184
188
|
* @param filterDes 描述过滤
|
|
185
189
|
* @returns 节点数组
|
|
186
190
|
*/
|
|
187
|
-
findByText(text: string, { filterClass, filterViewId, filterDes }?: {
|
|
191
|
+
findByText(text: string, { filterClass, filterViewId, filterDes, }?: {
|
|
188
192
|
filterClass?: string;
|
|
189
193
|
filterViewId?: string;
|
|
190
194
|
filterDes?: string;
|
|
@@ -197,7 +201,7 @@ export declare class Step {
|
|
|
197
201
|
* @param filterDes 描述过滤
|
|
198
202
|
* @returns 节点数组
|
|
199
203
|
*/
|
|
200
|
-
findByTags(className: string, { filterText, filterViewId, filterDes }?: {
|
|
204
|
+
findByTags(className: string, { filterText, filterViewId, filterDes, }?: {
|
|
201
205
|
filterText?: string;
|
|
202
206
|
filterViewId?: string;
|
|
203
207
|
filterDes?: string;
|
|
@@ -219,12 +223,6 @@ export declare class Step {
|
|
|
219
223
|
* @returns 文本数组
|
|
220
224
|
*/
|
|
221
225
|
getAllText(): string[];
|
|
222
|
-
/**
|
|
223
|
-
* 查找第一个匹配标签的父节点
|
|
224
|
-
* @param className 类名
|
|
225
|
-
* @returns 父节点
|
|
226
|
-
*/
|
|
227
|
-
findFirstParentByTags(className: string): Node;
|
|
228
226
|
/**
|
|
229
227
|
* 执行点击手势
|
|
230
228
|
* @param x 横坐标
|
|
@@ -236,7 +234,7 @@ export declare class Step {
|
|
|
236
234
|
longPressGestureAutoPaste(point: {
|
|
237
235
|
x: number;
|
|
238
236
|
y: number;
|
|
239
|
-
}, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration }?: {
|
|
237
|
+
}, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
|
|
240
238
|
matchedPackageName?: string;
|
|
241
239
|
matchedText?: string;
|
|
242
240
|
timeoutMillis?: number;
|
package/dist/Step.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* 用于管理和执行自动化步骤,提供步骤的生命周期管理、状态控制和界面操作功能
|
|
4
4
|
*/
|
|
5
5
|
import { AssistsX } from "./AssistsX";
|
|
6
|
-
import { useStepStore } from
|
|
6
|
+
import { useStepStore } from "./StepStateStore";
|
|
7
7
|
import { generateUUID } from "./Utils";
|
|
8
|
+
import { StepError } from "./StepError";
|
|
9
|
+
import { StepAsync } from "./StepAsync";
|
|
8
10
|
export class Step {
|
|
9
11
|
/**
|
|
10
12
|
* 运行步骤实现
|
|
@@ -13,38 +15,47 @@ export class Step {
|
|
|
13
15
|
* @param data 步骤数据
|
|
14
16
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
15
17
|
*/
|
|
16
|
-
static async run(impl, { tag, data, delayMs = Step.delayMsDefault } = {}) {
|
|
18
|
+
static async run(impl, { tag, data, delayMs = Step.delayMsDefault, } = {}) {
|
|
17
19
|
var _a;
|
|
18
20
|
const stepStore = useStepStore();
|
|
19
21
|
let implnName = impl.name;
|
|
22
|
+
let currentStep;
|
|
23
|
+
let nextStep;
|
|
20
24
|
try {
|
|
21
25
|
//步骤开始
|
|
22
26
|
this._stepId = generateUUID();
|
|
23
27
|
stepStore.startStep(this._stepId, tag, data);
|
|
24
|
-
|
|
28
|
+
currentStep = new Step({
|
|
29
|
+
stepId: this._stepId,
|
|
30
|
+
impl,
|
|
31
|
+
tag,
|
|
32
|
+
data,
|
|
33
|
+
delayMs,
|
|
34
|
+
});
|
|
25
35
|
while (true) {
|
|
26
|
-
if (
|
|
36
|
+
if (currentStep.delayMs) {
|
|
27
37
|
if (Step.showLog) {
|
|
28
|
-
console.log(`延迟${
|
|
38
|
+
console.log(`延迟${currentStep.delayMs}毫秒`);
|
|
29
39
|
}
|
|
30
|
-
await
|
|
31
|
-
Step.assert(
|
|
40
|
+
await currentStep.delay(currentStep.delayMs);
|
|
41
|
+
Step.assert(currentStep.stepId);
|
|
32
42
|
}
|
|
33
43
|
//执行步骤
|
|
34
|
-
implnName =
|
|
44
|
+
implnName = currentStep.impl.name;
|
|
35
45
|
if (Step.showLog) {
|
|
36
|
-
console.log(`执行步骤${implnName},重复次数${
|
|
46
|
+
console.log(`执行步骤${implnName},重复次数${currentStep.repeatCount}`);
|
|
37
47
|
}
|
|
38
|
-
|
|
39
|
-
if (
|
|
48
|
+
nextStep = await currentStep.impl(currentStep);
|
|
49
|
+
if (currentStep.repeatCountMax > Step.repeatCountInfinite &&
|
|
50
|
+
currentStep.repeatCount > currentStep.repeatCountMax) {
|
|
40
51
|
if (Step.showLog) {
|
|
41
|
-
console.log(`重复次数${
|
|
52
|
+
console.log(`重复次数${currentStep.repeatCount}超过最大次数${currentStep.repeatCountMax},停止执行`);
|
|
42
53
|
}
|
|
43
54
|
break;
|
|
44
55
|
}
|
|
45
|
-
Step.assert(
|
|
56
|
+
Step.assert(currentStep.stepId);
|
|
46
57
|
if (nextStep) {
|
|
47
|
-
|
|
58
|
+
currentStep = nextStep;
|
|
48
59
|
}
|
|
49
60
|
else {
|
|
50
61
|
break;
|
|
@@ -60,13 +71,14 @@ export class Step {
|
|
|
60
71
|
impl: implnName,
|
|
61
72
|
tag: tag,
|
|
62
73
|
data: data,
|
|
63
|
-
error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e)
|
|
74
|
+
error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e),
|
|
64
75
|
});
|
|
65
76
|
stepStore.setError(errorMsg);
|
|
66
|
-
throw new
|
|
77
|
+
throw new StepError(errorMsg, implnName, tag, data, e, currentStep || undefined);
|
|
67
78
|
}
|
|
68
79
|
//步骤执行结束
|
|
69
80
|
stepStore.completeStep();
|
|
81
|
+
return currentStep;
|
|
70
82
|
}
|
|
71
83
|
/**
|
|
72
84
|
* 获取当前步骤ID
|
|
@@ -75,7 +87,7 @@ export class Step {
|
|
|
75
87
|
return this._stepId;
|
|
76
88
|
}
|
|
77
89
|
/**
|
|
78
|
-
* 验证步骤ID
|
|
90
|
+
* 验证步骤ID是否匹配,如果不匹配则表示停止
|
|
79
91
|
* @param stepId 要验证的步骤ID
|
|
80
92
|
*/
|
|
81
93
|
static assert(stepId) {
|
|
@@ -90,7 +102,7 @@ export class Step {
|
|
|
90
102
|
*/
|
|
91
103
|
static assignIdsToNodes(nodes, stepId) {
|
|
92
104
|
if (stepId) {
|
|
93
|
-
nodes.forEach(node => {
|
|
105
|
+
nodes.forEach((node) => {
|
|
94
106
|
node.stepId = stepId;
|
|
95
107
|
});
|
|
96
108
|
}
|
|
@@ -109,7 +121,7 @@ export class Step {
|
|
|
109
121
|
* @param data 步骤数据
|
|
110
122
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
111
123
|
*/
|
|
112
|
-
constructor({ stepId, impl, tag, data, delayMs = Step.delayMsDefault, repeatCountMax = Step.repeatCountMaxDefault }) {
|
|
124
|
+
constructor({ stepId, impl, tag, data, delayMs = Step.delayMsDefault, repeatCountMax = Step.repeatCountMaxDefault, }) {
|
|
113
125
|
/**
|
|
114
126
|
* 步骤ID
|
|
115
127
|
*/
|
|
@@ -133,6 +145,9 @@ export class Step {
|
|
|
133
145
|
this.delayMs = delayMs;
|
|
134
146
|
this.repeatCountMax = repeatCountMax;
|
|
135
147
|
}
|
|
148
|
+
get async() {
|
|
149
|
+
return new StepAsync(this);
|
|
150
|
+
}
|
|
136
151
|
/**
|
|
137
152
|
* 创建下一个步骤
|
|
138
153
|
* @param impl 下一步骤实现函数
|
|
@@ -141,9 +156,16 @@ export class Step {
|
|
|
141
156
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
142
157
|
* @returns 新的步骤实例
|
|
143
158
|
*/
|
|
144
|
-
next(impl, { tag, data, delayMs = Step.delayMsDefault, repeatCountMax = Step.repeatCountMaxDefault } = {}) {
|
|
145
|
-
Step.assert(this.stepId);
|
|
146
|
-
return new Step({
|
|
159
|
+
next(impl, { tag, data, delayMs = Step.delayMsDefault, repeatCountMax = Step.repeatCountMaxDefault, } = {}) {
|
|
160
|
+
Step.assert(this.stepId);
|
|
161
|
+
return new Step({
|
|
162
|
+
stepId: this.stepId,
|
|
163
|
+
impl,
|
|
164
|
+
tag,
|
|
165
|
+
data: data !== null && data !== void 0 ? data : this.data,
|
|
166
|
+
delayMs,
|
|
167
|
+
repeatCountMax,
|
|
168
|
+
});
|
|
147
169
|
}
|
|
148
170
|
/**
|
|
149
171
|
* 重复当前步骤
|
|
@@ -153,7 +175,7 @@ export class Step {
|
|
|
153
175
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
154
176
|
* @returns 当前步骤实例
|
|
155
177
|
*/
|
|
156
|
-
repeat({ stepId = this.stepId, tag = this.tag, data = this.data, delayMs = this.delayMs, repeatCountMax = this.repeatCountMax } = {}) {
|
|
178
|
+
repeat({ stepId = this.stepId, tag = this.tag, data = this.data, delayMs = this.delayMs, repeatCountMax = this.repeatCountMax, } = {}) {
|
|
157
179
|
Step.assert(this.stepId);
|
|
158
180
|
this.repeatCount++;
|
|
159
181
|
this.stepId = stepId;
|
|
@@ -225,9 +247,14 @@ export class Step {
|
|
|
225
247
|
* @param filterText 文本过滤
|
|
226
248
|
* @returns 节点数组
|
|
227
249
|
*/
|
|
228
|
-
getAllNodes({ filterClass, filterViewId, filterDes, filterText } = {}) {
|
|
250
|
+
getAllNodes({ filterClass, filterViewId, filterDes, filterText, } = {}) {
|
|
229
251
|
Step.assert(this.stepId);
|
|
230
|
-
const nodes = AssistsX.getAllNodes({
|
|
252
|
+
const nodes = AssistsX.getAllNodes({
|
|
253
|
+
filterClass,
|
|
254
|
+
filterViewId,
|
|
255
|
+
filterDes,
|
|
256
|
+
filterText,
|
|
257
|
+
});
|
|
231
258
|
Step.assert(this.stepId);
|
|
232
259
|
Step.assignIdsToNodes(nodes, this.stepId);
|
|
233
260
|
return nodes;
|
|
@@ -261,7 +288,7 @@ export class Step {
|
|
|
261
288
|
* @param filterDes 描述过滤
|
|
262
289
|
* @returns 节点数组
|
|
263
290
|
*/
|
|
264
|
-
findById(id, { filterClass, filterText, filterDes } = {}) {
|
|
291
|
+
findById(id, { filterClass, filterText, filterDes, } = {}) {
|
|
265
292
|
Step.assert(this.stepId);
|
|
266
293
|
const nodes = AssistsX.findById(id, { filterClass, filterText, filterDes });
|
|
267
294
|
Step.assert(this.stepId);
|
|
@@ -276,9 +303,13 @@ export class Step {
|
|
|
276
303
|
* @param filterDes 描述过滤
|
|
277
304
|
* @returns 节点数组
|
|
278
305
|
*/
|
|
279
|
-
findByText(text, { filterClass, filterViewId, filterDes } = {}) {
|
|
306
|
+
findByText(text, { filterClass, filterViewId, filterDes, } = {}) {
|
|
280
307
|
Step.assert(this.stepId);
|
|
281
|
-
const nodes = AssistsX.findByText(text, {
|
|
308
|
+
const nodes = AssistsX.findByText(text, {
|
|
309
|
+
filterClass,
|
|
310
|
+
filterViewId,
|
|
311
|
+
filterDes,
|
|
312
|
+
});
|
|
282
313
|
Step.assert(this.stepId);
|
|
283
314
|
Step.assignIdsToNodes(nodes, this.stepId);
|
|
284
315
|
return nodes;
|
|
@@ -291,9 +322,13 @@ export class Step {
|
|
|
291
322
|
* @param filterDes 描述过滤
|
|
292
323
|
* @returns 节点数组
|
|
293
324
|
*/
|
|
294
|
-
findByTags(className, { filterText, filterViewId, filterDes } = {}) {
|
|
325
|
+
findByTags(className, { filterText, filterViewId, filterDes, } = {}) {
|
|
295
326
|
Step.assert(this.stepId);
|
|
296
|
-
const nodes = AssistsX.findByTags(className, {
|
|
327
|
+
const nodes = AssistsX.findByTags(className, {
|
|
328
|
+
filterText,
|
|
329
|
+
filterViewId,
|
|
330
|
+
filterDes,
|
|
331
|
+
});
|
|
297
332
|
Step.assert(this.stepId);
|
|
298
333
|
Step.assignIdsToNodes(nodes, this.stepId);
|
|
299
334
|
return nodes;
|
|
@@ -331,17 +366,6 @@ export class Step {
|
|
|
331
366
|
Step.assert(this.stepId);
|
|
332
367
|
return texts;
|
|
333
368
|
}
|
|
334
|
-
/**
|
|
335
|
-
* 查找第一个匹配标签的父节点
|
|
336
|
-
* @param className 类名
|
|
337
|
-
* @returns 父节点
|
|
338
|
-
*/
|
|
339
|
-
findFirstParentByTags(className) {
|
|
340
|
-
Step.assert(this.stepId);
|
|
341
|
-
const node = AssistsX.findFirstParentByTags(className);
|
|
342
|
-
Step.assert(this.stepId);
|
|
343
|
-
return node;
|
|
344
|
-
}
|
|
345
369
|
/**
|
|
346
370
|
* 执行点击手势
|
|
347
371
|
* @param x 横坐标
|
|
@@ -355,9 +379,14 @@ export class Step {
|
|
|
355
379
|
Step.assert(this.stepId);
|
|
356
380
|
return result;
|
|
357
381
|
}
|
|
358
|
-
async longPressGestureAutoPaste(point, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
382
|
+
async longPressGestureAutoPaste(point, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
359
383
|
Step.assert(this.stepId);
|
|
360
|
-
const result = await AssistsX.longPressGestureAutoPaste(point, text, {
|
|
384
|
+
const result = await AssistsX.longPressGestureAutoPaste(point, text, {
|
|
385
|
+
matchedPackageName,
|
|
386
|
+
matchedText,
|
|
387
|
+
timeoutMillis,
|
|
388
|
+
longPressDuration,
|
|
389
|
+
});
|
|
361
390
|
Step.assert(this.stepId);
|
|
362
391
|
return result;
|
|
363
392
|
}
|
|
@@ -369,7 +398,9 @@ export class Step {
|
|
|
369
398
|
}
|
|
370
399
|
async performLinearGesture(startPoint, endPoint, { duration } = {}) {
|
|
371
400
|
Step.assert(this.stepId);
|
|
372
|
-
const result = await AssistsX.performLinearGesture(startPoint, endPoint, {
|
|
401
|
+
const result = await AssistsX.performLinearGesture(startPoint, endPoint, {
|
|
402
|
+
duration,
|
|
403
|
+
});
|
|
373
404
|
Step.assert(this.stepId);
|
|
374
405
|
return result;
|
|
375
406
|
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Node } from "./Node";
|
|
2
|
+
import { Step } from "./Step";
|
|
3
|
+
export declare class StepAsync {
|
|
4
|
+
private step;
|
|
5
|
+
/**
|
|
6
|
+
* 构造函数
|
|
7
|
+
* @param step Step实例
|
|
8
|
+
*/
|
|
9
|
+
constructor(step: Step);
|
|
10
|
+
/**
|
|
11
|
+
* 对单个节点进行截图
|
|
12
|
+
* @param node 目标节点
|
|
13
|
+
* @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
|
|
14
|
+
* @returns 截图路径
|
|
15
|
+
*/
|
|
16
|
+
takeScreenshotByNode(node: Node, overlayHiddenScreenshotDelayMillis?: number): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* 对多个节点进行截图
|
|
19
|
+
* @param nodes 目标节点数组
|
|
20
|
+
* @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
|
|
21
|
+
* @returns 截图路径数组
|
|
22
|
+
*/
|
|
23
|
+
takeScreenshotNodes(nodes: Node[], overlayHiddenScreenshotDelayMillis?: number): Promise<string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* 获取所有符合条件的节点
|
|
26
|
+
* @param filterClass 类名过滤
|
|
27
|
+
* @param filterViewId 视图ID过滤
|
|
28
|
+
* @param filterDes 描述过滤
|
|
29
|
+
* @param filterText 文本过滤
|
|
30
|
+
* @returns 节点数组
|
|
31
|
+
*/
|
|
32
|
+
getAllNodes({ filterClass, filterViewId, filterDes, filterText, }?: {
|
|
33
|
+
filterClass?: string;
|
|
34
|
+
filterViewId?: string;
|
|
35
|
+
filterDes?: string;
|
|
36
|
+
filterText?: string;
|
|
37
|
+
}): Promise<Node[]>;
|
|
38
|
+
/**
|
|
39
|
+
* 启动应用
|
|
40
|
+
* @param packageName 应用包名
|
|
41
|
+
* @returns 是否启动成功
|
|
42
|
+
*/
|
|
43
|
+
launchApp(packageName: string): Promise<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* 获取当前应用包名
|
|
46
|
+
* @returns 包名
|
|
47
|
+
*/
|
|
48
|
+
getPackageName(): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* 通过ID查找节点
|
|
51
|
+
* @param id 节点ID
|
|
52
|
+
* @param filterClass 类名过滤
|
|
53
|
+
* @param filterText 文本过滤
|
|
54
|
+
* @param filterDes 描述过滤
|
|
55
|
+
* @returns 节点数组
|
|
56
|
+
*/
|
|
57
|
+
findById(id: string, { filterClass, filterText, filterDes, }?: {
|
|
58
|
+
filterClass?: string;
|
|
59
|
+
filterText?: string;
|
|
60
|
+
filterDes?: string;
|
|
61
|
+
}): Promise<Node[]>;
|
|
62
|
+
/**
|
|
63
|
+
* 通过文本查找节点
|
|
64
|
+
* @param text 要查找的文本
|
|
65
|
+
* @param filterClass 类名过滤
|
|
66
|
+
* @param filterViewId 视图ID过滤
|
|
67
|
+
* @param filterDes 描述过滤
|
|
68
|
+
* @returns 节点数组
|
|
69
|
+
*/
|
|
70
|
+
findByText(text: string, { filterClass, filterViewId, filterDes, }?: {
|
|
71
|
+
filterClass?: string;
|
|
72
|
+
filterViewId?: string;
|
|
73
|
+
filterDes?: string;
|
|
74
|
+
}): Promise<Node[]>;
|
|
75
|
+
/**
|
|
76
|
+
* 通过标签查找节点
|
|
77
|
+
* @param className 类名
|
|
78
|
+
* @param filterText 文本过滤
|
|
79
|
+
* @param filterViewId 视图ID过滤
|
|
80
|
+
* @param filterDes 描述过滤
|
|
81
|
+
* @returns 节点数组
|
|
82
|
+
*/
|
|
83
|
+
findByTags(className: string, { filterText, filterViewId, filterDes, }?: {
|
|
84
|
+
filterText?: string;
|
|
85
|
+
filterViewId?: string;
|
|
86
|
+
filterDes?: string;
|
|
87
|
+
}): Promise<Node[]>;
|
|
88
|
+
/**
|
|
89
|
+
* 查找所有匹配文本的节点
|
|
90
|
+
* @param text 要查找的文本
|
|
91
|
+
* @returns 节点数组
|
|
92
|
+
*/
|
|
93
|
+
findByTextAllMatch(text: string): Promise<Node[]>;
|
|
94
|
+
/**
|
|
95
|
+
* 检查是否包含指定文本
|
|
96
|
+
* @param text 要检查的文本
|
|
97
|
+
* @returns 是否包含
|
|
98
|
+
*/
|
|
99
|
+
containsText(text: string): Promise<boolean>;
|
|
100
|
+
/**
|
|
101
|
+
* 获取所有文本
|
|
102
|
+
* @returns 文本数组
|
|
103
|
+
*/
|
|
104
|
+
getAllText(): Promise<string[]>;
|
|
105
|
+
/**
|
|
106
|
+
* 执行点击手势
|
|
107
|
+
* @param x 横坐标
|
|
108
|
+
* @param y 纵坐标
|
|
109
|
+
* @param duration 持续时间(毫秒)
|
|
110
|
+
* @returns 是否成功
|
|
111
|
+
*/
|
|
112
|
+
clickByGesture(x: number, y: number, duration: number): Promise<boolean>;
|
|
113
|
+
longPressGestureAutoPaste(point: {
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
}, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
|
|
117
|
+
matchedPackageName?: string;
|
|
118
|
+
matchedText?: string;
|
|
119
|
+
timeoutMillis?: number;
|
|
120
|
+
longPressDuration?: number;
|
|
121
|
+
}): Promise<boolean>;
|
|
122
|
+
getAppInfo(packageName: string): Promise<any>;
|
|
123
|
+
performLinearGesture(startPoint: {
|
|
124
|
+
x: number;
|
|
125
|
+
y: number;
|
|
126
|
+
}, endPoint: {
|
|
127
|
+
x: number;
|
|
128
|
+
y: number;
|
|
129
|
+
}, { duration }?: {
|
|
130
|
+
duration?: number;
|
|
131
|
+
}): Promise<boolean>;
|
|
132
|
+
/**
|
|
133
|
+
* 返回操作
|
|
134
|
+
* @returns 是否成功
|
|
135
|
+
*/
|
|
136
|
+
back(): Promise<boolean>;
|
|
137
|
+
/**
|
|
138
|
+
* 回到主页
|
|
139
|
+
* @returns 是否成功
|
|
140
|
+
*/
|
|
141
|
+
home(): Promise<boolean>;
|
|
142
|
+
/**
|
|
143
|
+
* 打开通知栏
|
|
144
|
+
* @returns 是否成功
|
|
145
|
+
*/
|
|
146
|
+
notifications(): Promise<boolean>;
|
|
147
|
+
/**
|
|
148
|
+
* 显示最近应用
|
|
149
|
+
* @returns 是否成功
|
|
150
|
+
*/
|
|
151
|
+
recentApps(): Promise<boolean>;
|
|
152
|
+
/**
|
|
153
|
+
* 获取屏幕尺寸
|
|
154
|
+
* @returns 屏幕尺寸对象
|
|
155
|
+
*/
|
|
156
|
+
getScreenSize(): Promise<any>;
|
|
157
|
+
/**
|
|
158
|
+
* 获取应用窗口尺寸
|
|
159
|
+
* @returns 应用窗口尺寸对象
|
|
160
|
+
*/
|
|
161
|
+
getAppScreenSize(): Promise<any>;
|
|
162
|
+
}
|