assistsx-js 0.0.2047 → 0.0.2048
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/Node.d.ts +1 -1
- package/dist/Node.js +9 -1
- package/package.json +1 -1
- package/src/Node.ts +526 -523
package/dist/Node.d.ts
CHANGED
package/dist/Node.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 节点类
|
|
3
|
+
* 表示界面上的一个可交互元素,包含元素的属性和可执行的操作
|
|
4
|
+
*/
|
|
5
|
+
import { Bounds } from "./Bounds";
|
|
1
6
|
import { AssistsX } from "./AssistsX";
|
|
2
7
|
import { Step } from "./Step";
|
|
3
8
|
import { NodeAsync } from "./NodeAsync";
|
|
@@ -27,7 +32,10 @@ export class Node {
|
|
|
27
32
|
this.isSelected = params.isSelected;
|
|
28
33
|
this.isVisibleToUser = params.isVisibleToUser;
|
|
29
34
|
this.drawingOrder = params.drawingOrder;
|
|
30
|
-
|
|
35
|
+
// 确保 boundsInScreen 是 Bounds 实例,如果不是则转换
|
|
36
|
+
this.boundsInScreen = params.boundsInScreen instanceof Bounds
|
|
37
|
+
? params.boundsInScreen
|
|
38
|
+
: Bounds.fromData(params.boundsInScreen);
|
|
31
39
|
}
|
|
32
40
|
get async() {
|
|
33
41
|
return new NodeAsync(this);
|
package/package.json
CHANGED
package/src/Node.ts
CHANGED
|
@@ -9,548 +9,551 @@ import { NodeAsync } from "./NodeAsync";
|
|
|
9
9
|
|
|
10
10
|
// 将接口改造为类
|
|
11
11
|
export class Node {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
nodeId: string;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 节点文本内容
|
|
19
|
-
*/
|
|
20
|
-
text: string;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 节点描述信息
|
|
24
|
-
*/
|
|
25
|
-
des: string;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 节点视图ID
|
|
29
|
-
*/
|
|
30
|
-
viewId: string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 节点类名
|
|
34
|
-
*/
|
|
35
|
-
className: string;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 是否可滚动
|
|
39
|
-
*/
|
|
40
|
-
isScrollable: boolean;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 是否可点击
|
|
44
|
-
*/
|
|
45
|
-
isClickable: boolean;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 是否启用
|
|
49
|
-
*/
|
|
50
|
-
isEnabled: boolean;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 所属步骤ID
|
|
54
|
-
*/
|
|
55
|
-
stepId: string | undefined;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 提示文本
|
|
59
|
-
*/
|
|
60
|
-
hintText: string;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* 是否可选择
|
|
64
|
-
*/
|
|
65
|
-
isCheckable: boolean;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 是否已选中
|
|
69
|
-
*/
|
|
70
|
-
isChecked: boolean;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 是否可聚焦
|
|
74
|
-
*/
|
|
75
|
-
isFocusable: boolean;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 是否已聚焦
|
|
79
|
-
*/
|
|
80
|
-
isFocused: boolean;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* 是否可长按
|
|
84
|
-
*/
|
|
85
|
-
isLongClickable: boolean;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* 是否为密码字段
|
|
89
|
-
*/
|
|
90
|
-
isPassword: boolean;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* 是否已选中
|
|
94
|
-
*/
|
|
95
|
-
isSelected: boolean;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* 是否对用户可见
|
|
99
|
-
*/
|
|
100
|
-
isVisibleToUser: boolean;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 绘制顺序
|
|
104
|
-
*/
|
|
105
|
-
drawingOrder: number;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* 节点在屏幕中的边界
|
|
109
|
-
*/
|
|
110
|
-
boundsInScreen: Bounds;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 构造函数
|
|
114
|
-
* @param params 节点参数对象
|
|
115
|
-
*/
|
|
116
|
-
constructor(params: {
|
|
12
|
+
/**
|
|
13
|
+
* 节点唯一标识
|
|
14
|
+
*/
|
|
117
15
|
nodeId: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 节点文本内容
|
|
19
|
+
*/
|
|
118
20
|
text: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 节点描述信息
|
|
24
|
+
*/
|
|
119
25
|
des: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 节点视图ID
|
|
29
|
+
*/
|
|
120
30
|
viewId: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 节点类名
|
|
34
|
+
*/
|
|
121
35
|
className: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 是否可滚动
|
|
39
|
+
*/
|
|
122
40
|
isScrollable: boolean;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 是否可点击
|
|
44
|
+
*/
|
|
123
45
|
isClickable: boolean;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 是否启用
|
|
49
|
+
*/
|
|
124
50
|
isEnabled: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 所属步骤ID
|
|
54
|
+
*/
|
|
125
55
|
stepId: string | undefined;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 提示文本
|
|
59
|
+
*/
|
|
126
60
|
hintText: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 是否可选择
|
|
64
|
+
*/
|
|
127
65
|
isCheckable: boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 是否已选中
|
|
69
|
+
*/
|
|
128
70
|
isChecked: boolean;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 是否可聚焦
|
|
74
|
+
*/
|
|
129
75
|
isFocusable: boolean;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 是否已聚焦
|
|
79
|
+
*/
|
|
130
80
|
isFocused: boolean;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 是否可长按
|
|
84
|
+
*/
|
|
131
85
|
isLongClickable: boolean;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 是否为密码字段
|
|
89
|
+
*/
|
|
132
90
|
isPassword: boolean;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 是否已选中
|
|
94
|
+
*/
|
|
133
95
|
isSelected: boolean;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 是否对用户可见
|
|
99
|
+
*/
|
|
134
100
|
isVisibleToUser: boolean;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 绘制顺序
|
|
104
|
+
*/
|
|
135
105
|
drawingOrder: number;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 节点在屏幕中的边界
|
|
109
|
+
*/
|
|
136
110
|
boundsInScreen: Bounds;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
clickDuration,
|
|
219
|
-
clickInterval,
|
|
220
|
-
}: {
|
|
221
|
-
offsetX?: number;
|
|
222
|
-
offsetY?: number;
|
|
223
|
-
switchWindowIntervalDelay?: number;
|
|
224
|
-
clickDuration?: number;
|
|
225
|
-
clickInterval?: number;
|
|
226
|
-
} = {}): Promise<boolean> {
|
|
227
|
-
Step.assert(this.stepId);
|
|
228
|
-
const result = await AssistsX.doubleClickNodeByGesture(this, {
|
|
229
|
-
offsetX,
|
|
230
|
-
offsetY,
|
|
231
|
-
switchWindowIntervalDelay,
|
|
232
|
-
clickDuration,
|
|
233
|
-
clickInterval,
|
|
234
|
-
});
|
|
235
|
-
Step.assert(this.stepId);
|
|
236
|
-
return result;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
public async longPressNodeByGestureAutoPaste(
|
|
240
|
-
text: string,
|
|
241
|
-
{
|
|
242
|
-
matchedPackageName,
|
|
243
|
-
matchedText,
|
|
244
|
-
timeoutMillis,
|
|
245
|
-
longPressDuration,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 构造函数
|
|
114
|
+
* @param params 节点参数对象
|
|
115
|
+
*/
|
|
116
|
+
constructor(params: {
|
|
117
|
+
nodeId: string;
|
|
118
|
+
text: string;
|
|
119
|
+
des: string;
|
|
120
|
+
viewId: string;
|
|
121
|
+
className: string;
|
|
122
|
+
isScrollable: boolean;
|
|
123
|
+
isClickable: boolean;
|
|
124
|
+
isEnabled: boolean;
|
|
125
|
+
stepId: string | undefined;
|
|
126
|
+
hintText: string;
|
|
127
|
+
isCheckable: boolean;
|
|
128
|
+
isChecked: boolean;
|
|
129
|
+
isFocusable: boolean;
|
|
130
|
+
isFocused: boolean;
|
|
131
|
+
isLongClickable: boolean;
|
|
132
|
+
isPassword: boolean;
|
|
133
|
+
isSelected: boolean;
|
|
134
|
+
isVisibleToUser: boolean;
|
|
135
|
+
drawingOrder: number;
|
|
136
|
+
boundsInScreen: Bounds | any;
|
|
137
|
+
}) {
|
|
138
|
+
this.nodeId = params.nodeId;
|
|
139
|
+
this.text = params.text;
|
|
140
|
+
this.des = params.des;
|
|
141
|
+
this.viewId = params.viewId;
|
|
142
|
+
this.className = params.className;
|
|
143
|
+
this.isScrollable = params.isScrollable;
|
|
144
|
+
this.isClickable = params.isClickable;
|
|
145
|
+
this.isEnabled = params.isEnabled;
|
|
146
|
+
this.stepId = params.stepId;
|
|
147
|
+
this.hintText = params.hintText;
|
|
148
|
+
this.isCheckable = params.isCheckable;
|
|
149
|
+
this.isChecked = params.isChecked;
|
|
150
|
+
this.isFocusable = params.isFocusable;
|
|
151
|
+
this.isFocused = params.isFocused;
|
|
152
|
+
this.isLongClickable = params.isLongClickable;
|
|
153
|
+
this.isPassword = params.isPassword;
|
|
154
|
+
this.isSelected = params.isSelected;
|
|
155
|
+
this.isVisibleToUser = params.isVisibleToUser;
|
|
156
|
+
this.drawingOrder = params.drawingOrder;
|
|
157
|
+
// 确保 boundsInScreen 是 Bounds 实例,如果不是则转换
|
|
158
|
+
this.boundsInScreen = params.boundsInScreen instanceof Bounds
|
|
159
|
+
? params.boundsInScreen
|
|
160
|
+
: Bounds.fromData(params.boundsInScreen);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
public get async(): NodeAsync {
|
|
164
|
+
return new NodeAsync(this);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 查找第一个匹配标签的父节点
|
|
169
|
+
* @param className 类名
|
|
170
|
+
* @returns 父节点
|
|
171
|
+
*/
|
|
172
|
+
public findFirstParentByTags(className: string): Node {
|
|
173
|
+
Step.assert(this.stepId);
|
|
174
|
+
const node = AssistsX.findFirstParentByTags(this, className);
|
|
175
|
+
Step.assert(this.stepId);
|
|
176
|
+
return node;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* 对节点执行点击手势
|
|
181
|
+
* @param offsetX X轴偏移
|
|
182
|
+
* @param offsetY Y轴偏移
|
|
183
|
+
* @param switchWindowIntervalDelay 窗口切换延迟
|
|
184
|
+
* @param clickDuration 点击持续时间
|
|
185
|
+
* @returns 是否点击成功
|
|
186
|
+
*/
|
|
187
|
+
public async clickNodeByGesture({
|
|
188
|
+
offsetX,
|
|
189
|
+
offsetY,
|
|
190
|
+
switchWindowIntervalDelay,
|
|
191
|
+
clickDuration,
|
|
246
192
|
}: {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
} = {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
193
|
+
offsetX?: number;
|
|
194
|
+
offsetY?: number;
|
|
195
|
+
switchWindowIntervalDelay?: number;
|
|
196
|
+
clickDuration?: number;
|
|
197
|
+
} = {}): Promise<boolean> {
|
|
198
|
+
Step.assert(this.stepId);
|
|
199
|
+
const result = await AssistsX.clickNodeByGesture(this, {
|
|
200
|
+
offsetX,
|
|
201
|
+
offsetY,
|
|
202
|
+
switchWindowIntervalDelay,
|
|
203
|
+
clickDuration,
|
|
204
|
+
});
|
|
205
|
+
Step.assert(this.stepId);
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* 对节点执行双击手势
|
|
210
|
+
* @param offsetX X轴偏移
|
|
211
|
+
* @param offsetY Y轴偏移
|
|
212
|
+
* @param switchWindowIntervalDelay 窗口切换延迟
|
|
213
|
+
* @param clickDuration 点击持续时间
|
|
214
|
+
* @param clickInterval 点击间隔
|
|
215
|
+
* @returns 是否双击成功
|
|
216
|
+
*/
|
|
217
|
+
public async doubleClickNodeByGesture({
|
|
218
|
+
offsetX,
|
|
219
|
+
offsetY,
|
|
220
|
+
switchWindowIntervalDelay,
|
|
221
|
+
clickDuration,
|
|
222
|
+
clickInterval,
|
|
223
|
+
}: {
|
|
224
|
+
offsetX?: number;
|
|
225
|
+
offsetY?: number;
|
|
226
|
+
switchWindowIntervalDelay?: number;
|
|
227
|
+
clickDuration?: number;
|
|
228
|
+
clickInterval?: number;
|
|
229
|
+
} = {}): Promise<boolean> {
|
|
230
|
+
Step.assert(this.stepId);
|
|
231
|
+
const result = await AssistsX.doubleClickNodeByGesture(this, {
|
|
232
|
+
offsetX,
|
|
233
|
+
offsetY,
|
|
234
|
+
switchWindowIntervalDelay,
|
|
235
|
+
clickDuration,
|
|
236
|
+
clickInterval,
|
|
237
|
+
});
|
|
238
|
+
Step.assert(this.stepId);
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
public async longPressNodeByGestureAutoPaste(
|
|
243
|
+
text: string,
|
|
244
|
+
{
|
|
245
|
+
matchedPackageName,
|
|
246
|
+
matchedText,
|
|
247
|
+
timeoutMillis,
|
|
248
|
+
longPressDuration,
|
|
249
|
+
}: {
|
|
250
|
+
matchedPackageName?: string;
|
|
251
|
+
matchedText?: string;
|
|
252
|
+
timeoutMillis?: number;
|
|
253
|
+
longPressDuration?: number;
|
|
254
|
+
} = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }
|
|
255
|
+
): Promise<boolean> {
|
|
256
|
+
Step.assert(this.stepId);
|
|
257
|
+
const result = await AssistsX.longPressNodeByGestureAutoPaste(this, text, {
|
|
258
|
+
matchedPackageName,
|
|
259
|
+
matchedText,
|
|
260
|
+
timeoutMillis,
|
|
261
|
+
longPressDuration,
|
|
262
|
+
});
|
|
263
|
+
Step.assert(this.stepId);
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* 在当前节点范围内通过标签查找节点
|
|
269
|
+
* @param className 类名
|
|
270
|
+
* @param filterText 文本过滤
|
|
271
|
+
* @param filterViewId 视图ID过滤
|
|
272
|
+
* @param filterDes 描述过滤
|
|
273
|
+
* @returns 节点数组
|
|
274
|
+
*/
|
|
275
|
+
public findByTags(
|
|
276
|
+
className: string,
|
|
277
|
+
{
|
|
278
|
+
filterText,
|
|
279
|
+
filterViewId,
|
|
280
|
+
filterDes,
|
|
281
|
+
}: { filterText?: string; filterViewId?: string; filterDes?: string } = {}
|
|
282
|
+
): Node[] {
|
|
283
|
+
Step.assert(this.stepId);
|
|
284
|
+
const result = AssistsX.findByTags(className, {
|
|
285
|
+
filterText,
|
|
286
|
+
filterViewId,
|
|
287
|
+
filterDes,
|
|
288
|
+
node: this,
|
|
289
|
+
});
|
|
290
|
+
Step.assignIdsToNodes(result, this.stepId);
|
|
291
|
+
Step.assert(this.stepId);
|
|
292
|
+
return result;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* 在当前节点范围内通过ID查找节点
|
|
296
|
+
* @param id 节点ID
|
|
297
|
+
* @param filterClass 类名过滤
|
|
298
|
+
* @param filterText 文本过滤
|
|
299
|
+
* @param filterDes 描述过滤
|
|
300
|
+
* @returns 节点数组
|
|
301
|
+
*/
|
|
302
|
+
public findById(
|
|
303
|
+
id: string,
|
|
304
|
+
{
|
|
305
|
+
filterClass,
|
|
306
|
+
filterText,
|
|
307
|
+
filterDes,
|
|
308
|
+
}: { filterClass?: string; filterText?: string; filterDes?: string } = {}
|
|
309
|
+
): Node[] {
|
|
310
|
+
Step.assert(this.stepId);
|
|
311
|
+
const result = AssistsX.findById(id, {
|
|
312
|
+
filterClass,
|
|
313
|
+
filterText,
|
|
314
|
+
filterDes,
|
|
315
|
+
node: this,
|
|
316
|
+
});
|
|
317
|
+
Step.assignIdsToNodes(result, this.stepId);
|
|
318
|
+
Step.assert(this.stepId);
|
|
319
|
+
return result;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* 在当前节点范围内通过文本查找节点
|
|
323
|
+
* @param text 要查找的文本
|
|
324
|
+
* @param filterClass 类名过滤
|
|
325
|
+
* @param filterViewId 视图ID过滤
|
|
326
|
+
* @param filterDes 描述过滤
|
|
327
|
+
* @returns 节点数组
|
|
328
|
+
*/
|
|
329
|
+
public findByText(
|
|
330
|
+
text: string,
|
|
331
|
+
{
|
|
332
|
+
filterClass,
|
|
333
|
+
filterViewId,
|
|
334
|
+
filterDes,
|
|
335
|
+
}: { filterClass?: string; filterViewId?: string; filterDes?: string } = {}
|
|
336
|
+
): Node[] {
|
|
337
|
+
Step.assert(this.stepId);
|
|
338
|
+
const result = AssistsX.findByText(text, {
|
|
339
|
+
filterClass,
|
|
340
|
+
filterViewId,
|
|
341
|
+
filterDes,
|
|
342
|
+
node: this,
|
|
343
|
+
});
|
|
344
|
+
Step.assignIdsToNodes(result, this.stepId);
|
|
345
|
+
Step.assert(this.stepId);
|
|
346
|
+
return result;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* 向前滚动节点
|
|
351
|
+
* @returns 是否滚动成功
|
|
352
|
+
*/
|
|
353
|
+
public scrollForward(): boolean {
|
|
354
|
+
Step.assert(this.stepId);
|
|
355
|
+
const response = AssistsX.scrollForward(this);
|
|
356
|
+
Step.assert(this.stepId);
|
|
357
|
+
return response;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* 向后滚动节点
|
|
362
|
+
* @returns 是否滚动成功
|
|
363
|
+
*/
|
|
364
|
+
public scrollBackward(): boolean {
|
|
365
|
+
Step.assert(this.stepId);
|
|
366
|
+
const response = AssistsX.scrollBackward(this);
|
|
367
|
+
Step.assert(this.stepId);
|
|
368
|
+
return response;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* 检查节点是否可见
|
|
372
|
+
* @param compareNode 比较节点
|
|
373
|
+
* @param isFullyByCompareNode 是否完全可见
|
|
374
|
+
* @returns 是否可见
|
|
375
|
+
*/
|
|
376
|
+
public isVisible({
|
|
377
|
+
compareNode,
|
|
378
|
+
isFullyByCompareNode,
|
|
379
|
+
}: { compareNode?: Node; isFullyByCompareNode?: boolean } = {}): boolean {
|
|
380
|
+
Step.assert(this.stepId);
|
|
381
|
+
const response = AssistsX.isVisible(this, {
|
|
382
|
+
compareNode,
|
|
383
|
+
isFullyByCompareNode,
|
|
384
|
+
});
|
|
385
|
+
Step.assert(this.stepId);
|
|
386
|
+
return response;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* 对节点进行截图
|
|
390
|
+
* @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
|
|
391
|
+
* @returns 截图路径
|
|
392
|
+
*/
|
|
393
|
+
public async takeScreenshot(
|
|
394
|
+
overlayHiddenScreenshotDelayMillis: number = 250
|
|
395
|
+
): Promise<string> {
|
|
396
|
+
Step.assert(this.stepId);
|
|
397
|
+
const result = await AssistsX.takeScreenshotNodes(
|
|
398
|
+
[this],
|
|
399
|
+
overlayHiddenScreenshotDelayMillis
|
|
400
|
+
);
|
|
401
|
+
Step.assert(this.stepId);
|
|
402
|
+
return result[0];
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* 设置节点文本
|
|
406
|
+
* @param text 要设置的文本
|
|
407
|
+
* @returns 是否设置成功
|
|
408
|
+
*/
|
|
409
|
+
public setNodeText(text: string): boolean {
|
|
410
|
+
Step.assert(this.stepId);
|
|
411
|
+
const result = AssistsX.setNodeText(this, text);
|
|
412
|
+
Step.assert(this.stepId);
|
|
413
|
+
return result;
|
|
414
|
+
}
|
|
415
|
+
public paste(text: string): boolean {
|
|
416
|
+
Step.assert(this.stepId);
|
|
417
|
+
const result = AssistsX.paste(this, text);
|
|
418
|
+
Step.assert(this.stepId);
|
|
419
|
+
return result;
|
|
420
|
+
}
|
|
421
|
+
public focus(): boolean {
|
|
422
|
+
Step.assert(this.stepId);
|
|
423
|
+
const result = AssistsX.focus(this);
|
|
424
|
+
Step.assert(this.stepId);
|
|
425
|
+
return result;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* 点击节点
|
|
430
|
+
* @returns 是否点击成功
|
|
431
|
+
*/
|
|
432
|
+
public click(): boolean {
|
|
433
|
+
Step.assert(this.stepId);
|
|
434
|
+
const result = AssistsX.click(this);
|
|
435
|
+
Step.assert(this.stepId);
|
|
436
|
+
return result;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* 长按节点
|
|
440
|
+
* @returns 是否长按成功
|
|
441
|
+
*/
|
|
442
|
+
public longClick(): boolean {
|
|
443
|
+
Step.assert(this.stepId);
|
|
444
|
+
const result = AssistsX.longClick(this);
|
|
445
|
+
Step.assert(this.stepId);
|
|
446
|
+
return result;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* 查找第一个可点击的父节点
|
|
450
|
+
* @returns 可点击的父节点
|
|
451
|
+
*/
|
|
452
|
+
public findFirstParentClickable(): Node {
|
|
453
|
+
Step.assert(this.stepId);
|
|
454
|
+
const result = AssistsX.findFirstParentClickable(this);
|
|
455
|
+
Step.assert(this.stepId);
|
|
456
|
+
Step.assignIdsToNodes([result], this.stepId);
|
|
457
|
+
return result;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* 获取节点在屏幕中的边界
|
|
461
|
+
* @returns 边界对象
|
|
462
|
+
*/
|
|
463
|
+
public getBoundsInScreen(): Bounds {
|
|
464
|
+
Step.assert(this.stepId);
|
|
465
|
+
const result = AssistsX.getBoundsInScreen(this);
|
|
466
|
+
Step.assert(this.stepId);
|
|
467
|
+
return result;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* 获取节点的所有子节点
|
|
471
|
+
* @returns 子节点数组
|
|
472
|
+
*/
|
|
473
|
+
public getNodes(): Node[] {
|
|
474
|
+
Step.assert(this.stepId);
|
|
475
|
+
const result = AssistsX.getNodes(this);
|
|
476
|
+
Step.assert(this.stepId);
|
|
477
|
+
Step.assignIdsToNodes(result, this.stepId);
|
|
478
|
+
return result;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* 获取节点的直接子节点
|
|
482
|
+
* @returns 子节点数组
|
|
483
|
+
*/
|
|
484
|
+
public getChildren(): Node[] {
|
|
485
|
+
Step.assert(this.stepId);
|
|
486
|
+
const result = AssistsX.getChildren(this);
|
|
487
|
+
Step.assert(this.stepId);
|
|
488
|
+
Step.assignIdsToNodes(result, this.stepId);
|
|
489
|
+
return result;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* 从JSON字符串创建节点实例
|
|
494
|
+
* @param json JSON字符串
|
|
495
|
+
* @returns 节点实例
|
|
496
|
+
*/
|
|
497
|
+
static fromJSON(json: string): Node {
|
|
498
|
+
const data = JSON.parse(json);
|
|
499
|
+
return new Node(data);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* 从普通对象创建节点实例
|
|
504
|
+
* @param data 对象数据
|
|
505
|
+
* @returns 节点实例
|
|
506
|
+
*/
|
|
507
|
+
static from(data: any): Node {
|
|
508
|
+
return new Node(data);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* JSON.parse的reviver函数,用于将解析的JSON对象转换为Node实例
|
|
513
|
+
* @param key 属性键
|
|
514
|
+
* @param value 属性值
|
|
515
|
+
* @returns 转换后的值
|
|
516
|
+
*/
|
|
517
|
+
static reviver(key: string, value: any): any {
|
|
518
|
+
return key === "" ? new Node(value) : value;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* 创建新的节点实例
|
|
523
|
+
* @param params 节点参数对象
|
|
524
|
+
* @returns 节点实例
|
|
525
|
+
*/
|
|
526
|
+
static create(params: {
|
|
527
|
+
nodeId: string;
|
|
528
|
+
text: string;
|
|
529
|
+
des: string;
|
|
530
|
+
viewId: string;
|
|
531
|
+
className: string;
|
|
532
|
+
isScrollable: boolean;
|
|
533
|
+
isClickable: boolean;
|
|
534
|
+
isEnabled: boolean;
|
|
535
|
+
stepId: string | undefined;
|
|
536
|
+
hintText: string;
|
|
537
|
+
isCheckable: boolean;
|
|
538
|
+
isChecked: boolean;
|
|
539
|
+
isFocusable: boolean;
|
|
540
|
+
isFocused: boolean;
|
|
541
|
+
isLongClickable: boolean;
|
|
542
|
+
isPassword: boolean;
|
|
543
|
+
isSelected: boolean;
|
|
544
|
+
isVisibleToUser: boolean;
|
|
545
|
+
drawingOrder: number;
|
|
546
|
+
boundsInScreen: Bounds;
|
|
547
|
+
}): Node {
|
|
548
|
+
return new Node(params);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* 从JSON数组创建节点数组
|
|
553
|
+
* @param array JSON数组
|
|
554
|
+
* @returns 节点数组
|
|
555
|
+
*/
|
|
556
|
+
static fromJSONArray(array: Array<any>): Node[] {
|
|
557
|
+
return array.map((data) => new Node(data));
|
|
558
|
+
}
|
|
556
559
|
}
|