assistsx-js 0.0.1353 → 0.0.2001
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 +27 -15
- package/dist/AssistsX.js +131 -47
- package/dist/AssistsXAsync.d.ts +324 -0
- package/dist/AssistsXAsync.js +531 -0
- package/dist/CallMethod.d.ts +1 -0
- package/dist/CallMethod.js +1 -0
- package/dist/Node.d.ts +11 -8
- package/dist/Node.js +64 -20
- package/dist/NodeAsync.d.ts +194 -0
- package/dist/NodeAsync.js +297 -0
- package/dist/Step.d.ts +32 -12
- package/dist/Step.js +79 -33
- package/dist/StepAsync.d.ts +168 -0
- package/dist/StepAsync.js +275 -0
- package/dist/StepError.d.ts +27 -0
- package/dist/StepError.js +15 -0
- package/dist/index.d.ts +13 -10
- package/dist/index.js +13 -10
- package/package.json +2 -2
- package/src/AssistsX.ts +808 -589
- package/src/AssistsXAsync.ts +719 -0
- package/src/CallMethod.ts +2 -1
- package/src/Node.ts +428 -323
- package/src/NodeAsync.ts +398 -0
- package/src/Step.ts +680 -491
- package/src/StepAsync.ts +377 -0
- package/src/StepError.ts +47 -0
- package/src/global.d.ts +12 -9
- package/src/index.ts +13 -10
package/dist/Step.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Node } from
|
|
1
|
+
import { Node } from "./Node";
|
|
2
|
+
import { StepAsync } from "./StepAsync";
|
|
2
3
|
export declare class Step {
|
|
3
4
|
static delayMsDefault: number;
|
|
4
5
|
static readonly repeatCountInfinite: number;
|
|
@@ -15,17 +16,20 @@ export declare class Step {
|
|
|
15
16
|
* @param data 步骤数据
|
|
16
17
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
17
18
|
*/
|
|
18
|
-
static run(impl: (step: Step) => Promise<Step | undefined>, { tag, data, delayMs }?: {
|
|
19
|
+
static run(impl: (step: Step) => Promise<Step | undefined>, { tag, data, backupSteps, delayMs, }?: {
|
|
19
20
|
tag?: string | undefined;
|
|
20
21
|
data?: any | undefined;
|
|
22
|
+
backupSteps?: {
|
|
23
|
+
[key: string]: (step: Step) => Promise<Step | undefined>;
|
|
24
|
+
} | undefined;
|
|
21
25
|
delayMs?: number;
|
|
22
|
-
}): Promise<
|
|
26
|
+
}): Promise<Step>;
|
|
23
27
|
/**
|
|
24
28
|
* 获取当前步骤ID
|
|
25
29
|
*/
|
|
26
30
|
static get stepId(): string | undefined;
|
|
27
31
|
/**
|
|
28
|
-
* 验证步骤ID
|
|
32
|
+
* 验证步骤ID是否匹配,如果不匹配则表示停止
|
|
29
33
|
* @param stepId 要验证的步骤ID
|
|
30
34
|
*/
|
|
31
35
|
static assert(stepId: string | undefined): void;
|
|
@@ -67,6 +71,12 @@ export declare class Step {
|
|
|
67
71
|
* 步骤实现函数
|
|
68
72
|
*/
|
|
69
73
|
impl: (step: Step) => Promise<Step | undefined>;
|
|
74
|
+
/**
|
|
75
|
+
* 备份步骤,可用于在指定的步骤中转向其他步骤
|
|
76
|
+
*/
|
|
77
|
+
backupSteps: {
|
|
78
|
+
[key: string]: (step: Step) => Promise<Step | undefined>;
|
|
79
|
+
} | undefined;
|
|
70
80
|
/**
|
|
71
81
|
* 构造函数
|
|
72
82
|
* @param stepId 步骤ID
|
|
@@ -75,14 +85,18 @@ export declare class Step {
|
|
|
75
85
|
* @param data 步骤数据
|
|
76
86
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
77
87
|
*/
|
|
78
|
-
constructor({ stepId, impl, tag, data, delayMs, repeatCountMax }: {
|
|
88
|
+
constructor({ stepId, impl, tag, data, backupSteps, delayMs, repeatCountMax, }: {
|
|
79
89
|
stepId: string;
|
|
80
90
|
impl: (step: Step) => Promise<Step | undefined>;
|
|
81
91
|
tag?: string | undefined;
|
|
82
92
|
data?: any | undefined;
|
|
93
|
+
backupSteps?: {
|
|
94
|
+
[key: string]: (step: Step) => Promise<Step | undefined>;
|
|
95
|
+
} | undefined;
|
|
83
96
|
delayMs?: number;
|
|
84
97
|
repeatCountMax?: number;
|
|
85
98
|
});
|
|
99
|
+
get async(): StepAsync;
|
|
86
100
|
/**
|
|
87
101
|
* 创建下一个步骤
|
|
88
102
|
* @param impl 下一步骤实现函数
|
|
@@ -91,9 +105,12 @@ export declare class Step {
|
|
|
91
105
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
92
106
|
* @returns 新的步骤实例
|
|
93
107
|
*/
|
|
94
|
-
next(impl: (step: Step) => Promise<Step | undefined>, { tag, data, delayMs, repeatCountMax }?: {
|
|
108
|
+
next(impl: (step: Step) => Promise<Step | undefined>, { tag, data, backupSteps, delayMs, repeatCountMax, }?: {
|
|
95
109
|
tag?: string | undefined;
|
|
96
110
|
data?: any | undefined;
|
|
111
|
+
backupSteps?: {
|
|
112
|
+
[key: string]: (step: Step) => Promise<Step | undefined>;
|
|
113
|
+
} | undefined;
|
|
97
114
|
delayMs?: number;
|
|
98
115
|
repeatCountMax?: number;
|
|
99
116
|
}): Step;
|
|
@@ -105,10 +122,13 @@ export declare class Step {
|
|
|
105
122
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
106
123
|
* @returns 当前步骤实例
|
|
107
124
|
*/
|
|
108
|
-
repeat({ stepId, tag, data, delayMs, repeatCountMax }?: {
|
|
125
|
+
repeat({ stepId, tag, data, backupSteps, delayMs, repeatCountMax, }?: {
|
|
109
126
|
stepId?: string;
|
|
110
127
|
tag?: string | undefined;
|
|
111
128
|
data?: any | undefined;
|
|
129
|
+
backupSteps?: {
|
|
130
|
+
[key: string]: (step: Step) => Promise<Step | undefined>;
|
|
131
|
+
} | undefined;
|
|
112
132
|
delayMs?: number;
|
|
113
133
|
repeatCountMax?: number;
|
|
114
134
|
}): Step;
|
|
@@ -146,7 +166,7 @@ export declare class Step {
|
|
|
146
166
|
* @param filterText 文本过滤
|
|
147
167
|
* @returns 节点数组
|
|
148
168
|
*/
|
|
149
|
-
getAllNodes({ filterClass, filterViewId, filterDes, filterText }?: {
|
|
169
|
+
getAllNodes({ filterClass, filterViewId, filterDes, filterText, }?: {
|
|
150
170
|
filterClass?: string;
|
|
151
171
|
filterViewId?: string;
|
|
152
172
|
filterDes?: string;
|
|
@@ -171,7 +191,7 @@ export declare class Step {
|
|
|
171
191
|
* @param filterDes 描述过滤
|
|
172
192
|
* @returns 节点数组
|
|
173
193
|
*/
|
|
174
|
-
findById(id: string, { filterClass, filterText, filterDes }?: {
|
|
194
|
+
findById(id: string, { filterClass, filterText, filterDes, }?: {
|
|
175
195
|
filterClass?: string;
|
|
176
196
|
filterText?: string;
|
|
177
197
|
filterDes?: string;
|
|
@@ -184,7 +204,7 @@ export declare class Step {
|
|
|
184
204
|
* @param filterDes 描述过滤
|
|
185
205
|
* @returns 节点数组
|
|
186
206
|
*/
|
|
187
|
-
findByText(text: string, { filterClass, filterViewId, filterDes }?: {
|
|
207
|
+
findByText(text: string, { filterClass, filterViewId, filterDes, }?: {
|
|
188
208
|
filterClass?: string;
|
|
189
209
|
filterViewId?: string;
|
|
190
210
|
filterDes?: string;
|
|
@@ -197,7 +217,7 @@ export declare class Step {
|
|
|
197
217
|
* @param filterDes 描述过滤
|
|
198
218
|
* @returns 节点数组
|
|
199
219
|
*/
|
|
200
|
-
findByTags(className: string, { filterText, filterViewId, filterDes }?: {
|
|
220
|
+
findByTags(className: string, { filterText, filterViewId, filterDes, }?: {
|
|
201
221
|
filterText?: string;
|
|
202
222
|
filterViewId?: string;
|
|
203
223
|
filterDes?: string;
|
|
@@ -236,7 +256,7 @@ export declare class Step {
|
|
|
236
256
|
longPressGestureAutoPaste(point: {
|
|
237
257
|
x: number;
|
|
238
258
|
y: number;
|
|
239
|
-
}, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration }?: {
|
|
259
|
+
}, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
|
|
240
260
|
matchedPackageName?: string;
|
|
241
261
|
matchedText?: string;
|
|
242
262
|
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,48 @@ 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, backupSteps, 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
|
+
backupSteps,
|
|
34
|
+
delayMs,
|
|
35
|
+
});
|
|
25
36
|
while (true) {
|
|
26
|
-
if (
|
|
37
|
+
if (currentStep.delayMs) {
|
|
27
38
|
if (Step.showLog) {
|
|
28
|
-
console.log(`延迟${
|
|
39
|
+
console.log(`延迟${currentStep.delayMs}毫秒`);
|
|
29
40
|
}
|
|
30
|
-
await
|
|
31
|
-
Step.assert(
|
|
41
|
+
await currentStep.delay(currentStep.delayMs);
|
|
42
|
+
Step.assert(currentStep.stepId);
|
|
32
43
|
}
|
|
33
44
|
//执行步骤
|
|
34
|
-
implnName =
|
|
45
|
+
implnName = currentStep.impl.name;
|
|
35
46
|
if (Step.showLog) {
|
|
36
|
-
console.log(`执行步骤${implnName},重复次数${
|
|
47
|
+
console.log(`执行步骤${implnName},重复次数${currentStep.repeatCount}`);
|
|
37
48
|
}
|
|
38
|
-
|
|
39
|
-
if (
|
|
49
|
+
nextStep = await currentStep.impl(currentStep);
|
|
50
|
+
if (currentStep.repeatCountMax > Step.repeatCountInfinite &&
|
|
51
|
+
currentStep.repeatCount > currentStep.repeatCountMax) {
|
|
40
52
|
if (Step.showLog) {
|
|
41
|
-
console.log(`重复次数${
|
|
53
|
+
console.log(`重复次数${currentStep.repeatCount}超过最大次数${currentStep.repeatCountMax},停止执行`);
|
|
42
54
|
}
|
|
43
55
|
break;
|
|
44
56
|
}
|
|
45
|
-
Step.assert(
|
|
57
|
+
Step.assert(currentStep.stepId);
|
|
46
58
|
if (nextStep) {
|
|
47
|
-
|
|
59
|
+
currentStep = nextStep;
|
|
48
60
|
}
|
|
49
61
|
else {
|
|
50
62
|
break;
|
|
@@ -60,13 +72,14 @@ export class Step {
|
|
|
60
72
|
impl: implnName,
|
|
61
73
|
tag: tag,
|
|
62
74
|
data: data,
|
|
63
|
-
error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e)
|
|
75
|
+
error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e),
|
|
64
76
|
});
|
|
65
77
|
stepStore.setError(errorMsg);
|
|
66
|
-
throw new
|
|
78
|
+
throw new StepError(errorMsg, implnName, tag, data, e, currentStep || undefined);
|
|
67
79
|
}
|
|
68
80
|
//步骤执行结束
|
|
69
81
|
stepStore.completeStep();
|
|
82
|
+
return currentStep;
|
|
70
83
|
}
|
|
71
84
|
/**
|
|
72
85
|
* 获取当前步骤ID
|
|
@@ -75,7 +88,7 @@ export class Step {
|
|
|
75
88
|
return this._stepId;
|
|
76
89
|
}
|
|
77
90
|
/**
|
|
78
|
-
* 验证步骤ID
|
|
91
|
+
* 验证步骤ID是否匹配,如果不匹配则表示停止
|
|
79
92
|
* @param stepId 要验证的步骤ID
|
|
80
93
|
*/
|
|
81
94
|
static assert(stepId) {
|
|
@@ -90,7 +103,7 @@ export class Step {
|
|
|
90
103
|
*/
|
|
91
104
|
static assignIdsToNodes(nodes, stepId) {
|
|
92
105
|
if (stepId) {
|
|
93
|
-
nodes.forEach(node => {
|
|
106
|
+
nodes.forEach((node) => {
|
|
94
107
|
node.stepId = stepId;
|
|
95
108
|
});
|
|
96
109
|
}
|
|
@@ -109,7 +122,7 @@ export class Step {
|
|
|
109
122
|
* @param data 步骤数据
|
|
110
123
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
111
124
|
*/
|
|
112
|
-
constructor({ stepId, impl, tag, data, delayMs = Step.delayMsDefault, repeatCountMax = Step.repeatCountMaxDefault }) {
|
|
125
|
+
constructor({ stepId, impl, tag, data, backupSteps, delayMs = Step.delayMsDefault, repeatCountMax = Step.repeatCountMaxDefault, }) {
|
|
113
126
|
/**
|
|
114
127
|
* 步骤ID
|
|
115
128
|
*/
|
|
@@ -130,9 +143,13 @@ export class Step {
|
|
|
130
143
|
this.stepId = stepId;
|
|
131
144
|
this.data = data;
|
|
132
145
|
this.impl = impl;
|
|
146
|
+
this.backupSteps = backupSteps;
|
|
133
147
|
this.delayMs = delayMs;
|
|
134
148
|
this.repeatCountMax = repeatCountMax;
|
|
135
149
|
}
|
|
150
|
+
get async() {
|
|
151
|
+
return new StepAsync(this);
|
|
152
|
+
}
|
|
136
153
|
/**
|
|
137
154
|
* 创建下一个步骤
|
|
138
155
|
* @param impl 下一步骤实现函数
|
|
@@ -141,9 +158,17 @@ export class Step {
|
|
|
141
158
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
142
159
|
* @returns 新的步骤实例
|
|
143
160
|
*/
|
|
144
|
-
next(impl, { tag, data, delayMs = Step.delayMsDefault, repeatCountMax = Step.repeatCountMaxDefault } = {}) {
|
|
145
|
-
Step.assert(this.stepId);
|
|
146
|
-
return new Step({
|
|
161
|
+
next(impl, { tag, data, backupSteps, delayMs = Step.delayMsDefault, repeatCountMax = Step.repeatCountMaxDefault, } = {}) {
|
|
162
|
+
Step.assert(this.stepId);
|
|
163
|
+
return new Step({
|
|
164
|
+
stepId: this.stepId,
|
|
165
|
+
impl,
|
|
166
|
+
tag,
|
|
167
|
+
data: data !== null && data !== void 0 ? data : this.data,
|
|
168
|
+
backupSteps: backupSteps !== null && backupSteps !== void 0 ? backupSteps : this.backupSteps,
|
|
169
|
+
delayMs,
|
|
170
|
+
repeatCountMax,
|
|
171
|
+
});
|
|
147
172
|
}
|
|
148
173
|
/**
|
|
149
174
|
* 重复当前步骤
|
|
@@ -153,12 +178,13 @@ export class Step {
|
|
|
153
178
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
154
179
|
* @returns 当前步骤实例
|
|
155
180
|
*/
|
|
156
|
-
repeat({ stepId = this.stepId, tag = this.tag, data = this.data, delayMs = this.delayMs, repeatCountMax = this.repeatCountMax } = {}) {
|
|
181
|
+
repeat({ stepId = this.stepId, tag = this.tag, data = this.data, backupSteps = this.backupSteps, delayMs = this.delayMs, repeatCountMax = this.repeatCountMax, } = {}) {
|
|
157
182
|
Step.assert(this.stepId);
|
|
158
183
|
this.repeatCount++;
|
|
159
184
|
this.stepId = stepId;
|
|
160
185
|
this.tag = tag;
|
|
161
186
|
this.data = data;
|
|
187
|
+
this.backupSteps = backupSteps;
|
|
162
188
|
this.delayMs = delayMs;
|
|
163
189
|
this.repeatCountMax = repeatCountMax;
|
|
164
190
|
return this;
|
|
@@ -225,9 +251,14 @@ export class Step {
|
|
|
225
251
|
* @param filterText 文本过滤
|
|
226
252
|
* @returns 节点数组
|
|
227
253
|
*/
|
|
228
|
-
getAllNodes({ filterClass, filterViewId, filterDes, filterText } = {}) {
|
|
254
|
+
getAllNodes({ filterClass, filterViewId, filterDes, filterText, } = {}) {
|
|
229
255
|
Step.assert(this.stepId);
|
|
230
|
-
const nodes = AssistsX.getAllNodes({
|
|
256
|
+
const nodes = AssistsX.getAllNodes({
|
|
257
|
+
filterClass,
|
|
258
|
+
filterViewId,
|
|
259
|
+
filterDes,
|
|
260
|
+
filterText,
|
|
261
|
+
});
|
|
231
262
|
Step.assert(this.stepId);
|
|
232
263
|
Step.assignIdsToNodes(nodes, this.stepId);
|
|
233
264
|
return nodes;
|
|
@@ -261,7 +292,7 @@ export class Step {
|
|
|
261
292
|
* @param filterDes 描述过滤
|
|
262
293
|
* @returns 节点数组
|
|
263
294
|
*/
|
|
264
|
-
findById(id, { filterClass, filterText, filterDes } = {}) {
|
|
295
|
+
findById(id, { filterClass, filterText, filterDes, } = {}) {
|
|
265
296
|
Step.assert(this.stepId);
|
|
266
297
|
const nodes = AssistsX.findById(id, { filterClass, filterText, filterDes });
|
|
267
298
|
Step.assert(this.stepId);
|
|
@@ -276,9 +307,13 @@ export class Step {
|
|
|
276
307
|
* @param filterDes 描述过滤
|
|
277
308
|
* @returns 节点数组
|
|
278
309
|
*/
|
|
279
|
-
findByText(text, { filterClass, filterViewId, filterDes } = {}) {
|
|
310
|
+
findByText(text, { filterClass, filterViewId, filterDes, } = {}) {
|
|
280
311
|
Step.assert(this.stepId);
|
|
281
|
-
const nodes = AssistsX.findByText(text, {
|
|
312
|
+
const nodes = AssistsX.findByText(text, {
|
|
313
|
+
filterClass,
|
|
314
|
+
filterViewId,
|
|
315
|
+
filterDes,
|
|
316
|
+
});
|
|
282
317
|
Step.assert(this.stepId);
|
|
283
318
|
Step.assignIdsToNodes(nodes, this.stepId);
|
|
284
319
|
return nodes;
|
|
@@ -291,9 +326,13 @@ export class Step {
|
|
|
291
326
|
* @param filterDes 描述过滤
|
|
292
327
|
* @returns 节点数组
|
|
293
328
|
*/
|
|
294
|
-
findByTags(className, { filterText, filterViewId, filterDes } = {}) {
|
|
329
|
+
findByTags(className, { filterText, filterViewId, filterDes, } = {}) {
|
|
295
330
|
Step.assert(this.stepId);
|
|
296
|
-
const nodes = AssistsX.findByTags(className, {
|
|
331
|
+
const nodes = AssistsX.findByTags(className, {
|
|
332
|
+
filterText,
|
|
333
|
+
filterViewId,
|
|
334
|
+
filterDes,
|
|
335
|
+
});
|
|
297
336
|
Step.assert(this.stepId);
|
|
298
337
|
Step.assignIdsToNodes(nodes, this.stepId);
|
|
299
338
|
return nodes;
|
|
@@ -355,9 +394,14 @@ export class Step {
|
|
|
355
394
|
Step.assert(this.stepId);
|
|
356
395
|
return result;
|
|
357
396
|
}
|
|
358
|
-
async longPressGestureAutoPaste(point, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
397
|
+
async longPressGestureAutoPaste(point, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
359
398
|
Step.assert(this.stepId);
|
|
360
|
-
const result = await AssistsX.longPressGestureAutoPaste(point, text, {
|
|
399
|
+
const result = await AssistsX.longPressGestureAutoPaste(point, text, {
|
|
400
|
+
matchedPackageName,
|
|
401
|
+
matchedText,
|
|
402
|
+
timeoutMillis,
|
|
403
|
+
longPressDuration,
|
|
404
|
+
});
|
|
361
405
|
Step.assert(this.stepId);
|
|
362
406
|
return result;
|
|
363
407
|
}
|
|
@@ -369,7 +413,9 @@ export class Step {
|
|
|
369
413
|
}
|
|
370
414
|
async performLinearGesture(startPoint, endPoint, { duration } = {}) {
|
|
371
415
|
Step.assert(this.stepId);
|
|
372
|
-
const result = await AssistsX.performLinearGesture(startPoint, endPoint, {
|
|
416
|
+
const result = await AssistsX.performLinearGesture(startPoint, endPoint, {
|
|
417
|
+
duration,
|
|
418
|
+
});
|
|
373
419
|
Step.assert(this.stepId);
|
|
374
420
|
return result;
|
|
375
421
|
}
|
|
@@ -0,0 +1,168 @@
|
|
|
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 className 类名
|
|
108
|
+
* @returns 父节点
|
|
109
|
+
*/
|
|
110
|
+
findFirstParentByTags(className: string): Promise<Node>;
|
|
111
|
+
/**
|
|
112
|
+
* 执行点击手势
|
|
113
|
+
* @param x 横坐标
|
|
114
|
+
* @param y 纵坐标
|
|
115
|
+
* @param duration 持续时间(毫秒)
|
|
116
|
+
* @returns 是否成功
|
|
117
|
+
*/
|
|
118
|
+
clickByGesture(x: number, y: number, duration: number): Promise<boolean>;
|
|
119
|
+
longPressGestureAutoPaste(point: {
|
|
120
|
+
x: number;
|
|
121
|
+
y: number;
|
|
122
|
+
}, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
|
|
123
|
+
matchedPackageName?: string;
|
|
124
|
+
matchedText?: string;
|
|
125
|
+
timeoutMillis?: number;
|
|
126
|
+
longPressDuration?: number;
|
|
127
|
+
}): Promise<boolean>;
|
|
128
|
+
getAppInfo(packageName: string): Promise<any>;
|
|
129
|
+
performLinearGesture(startPoint: {
|
|
130
|
+
x: number;
|
|
131
|
+
y: number;
|
|
132
|
+
}, endPoint: {
|
|
133
|
+
x: number;
|
|
134
|
+
y: number;
|
|
135
|
+
}, { duration }?: {
|
|
136
|
+
duration?: number;
|
|
137
|
+
}): Promise<boolean>;
|
|
138
|
+
/**
|
|
139
|
+
* 返回操作
|
|
140
|
+
* @returns 是否成功
|
|
141
|
+
*/
|
|
142
|
+
back(): Promise<boolean>;
|
|
143
|
+
/**
|
|
144
|
+
* 回到主页
|
|
145
|
+
* @returns 是否成功
|
|
146
|
+
*/
|
|
147
|
+
home(): Promise<boolean>;
|
|
148
|
+
/**
|
|
149
|
+
* 打开通知栏
|
|
150
|
+
* @returns 是否成功
|
|
151
|
+
*/
|
|
152
|
+
notifications(): Promise<boolean>;
|
|
153
|
+
/**
|
|
154
|
+
* 显示最近应用
|
|
155
|
+
* @returns 是否成功
|
|
156
|
+
*/
|
|
157
|
+
recentApps(): Promise<boolean>;
|
|
158
|
+
/**
|
|
159
|
+
* 获取屏幕尺寸
|
|
160
|
+
* @returns 屏幕尺寸对象
|
|
161
|
+
*/
|
|
162
|
+
getScreenSize(): Promise<any>;
|
|
163
|
+
/**
|
|
164
|
+
* 获取应用窗口尺寸
|
|
165
|
+
* @returns 应用窗口尺寸对象
|
|
166
|
+
*/
|
|
167
|
+
getAppScreenSize(): Promise<any>;
|
|
168
|
+
}
|