ms-vite-plugin 1.4.41 → 1.4.43

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.
@@ -1,450 +1,325 @@
1
1
  # 节点模块
2
2
 
3
- 节点模块提供了强大的 UI 元素访问和操作功能,可以通过各种条件选择和操作界面元素。
3
+ 用于查找和操作当前界面上的控件节点。
4
4
 
5
- **注意事项**
5
+ **注意**
6
6
 
7
- - 此模块仅支持 快点 Agent 模式使用
8
- - 节点用完需要调用 `释放内存` 方法释放内存,找完节点就能释放,不需要点击后释放
7
+ - 仅支持快点 Agent 模式
8
+ - 用完调用 `释放内存()`;找完节点即可释放,不必等点击结束
9
9
 
10
- ## 节点选择器 ($节点选择器)
10
+ **基本流程**
11
11
 
12
- 节点选择器是访问 UI 元素的核心工具,提供了灵活的筛选和查找机制。
13
-
14
- ### 创建节点选择器
12
+ ```text
13
+ $创建节点选择器 → 设置筛选条件 → 获取一个节点信息 / 获取节点信息
14
+ 点击 / 输入 / 设值等 → 释放内存
15
+ ```
15
16
 
16
- #### $创建节点选择器
17
+ ---
17
18
 
18
- 创建一个新的节点选择器实例。
19
+ ## 创建选择器
19
20
 
20
21
  ```typescript
21
22
  function $创建节点选择器(params?: {
22
- /**
23
- * 代表要获取节点的层级,越少速度越快,默认 50
24
- */
25
- maxDepth?: 数字;
26
- /**
27
- * 抓取模式:模式 1、模式 2、模式 3,默认模式 1
28
- */
29
- mode?: 数字;
23
+ maxDepth?: 数字; // 最大层级,默认 50;越小通常越快
24
+ mode?: 数字; // 抓取模式 1 | 2 | 3,默认 1
30
25
  }): $节点选择器;
31
26
  ```
32
27
 
33
- **参数说明:**
34
-
35
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
36
- | ---------- | ---- | -------- | ------ | --------------------------- |
37
- | `maxDepth` | 数字 | 否 | 50 | 遍历的最大层级深度,默认 50 |
38
- | `mode` | 数字 | 否 | 1 | 抓取模式。支持模式 1、模式 2、模式 3,默认模式 1 |
39
-
40
- **返回值:**
41
-
42
- | 类型 | 描述 |
43
- | ------------- | ---------------------- |
44
- | `$节点选择器` | 新创建的节点选择器实例 |
45
-
46
- **示例:**
47
-
48
- ```typescript
49
- // 创建选择器
50
- const selector = $创建节点选择器({
51
- maxDepth: 20, // 最大20层深度
52
- mode: 1, // 默认模式 1
53
- });
54
- ```
55
-
56
- ### 节点信息接口
57
-
58
- #### $节点位置信息
28
+ | 参数 | 默认 | 说明 |
29
+ | --- | --- | --- |
30
+ | `maxDepth` | `50` | 抓取深度,深层控件抓不到时可调大 |
31
+ | `mode` | `1` | 抓取模式,可选 `1` / `2` / `3`,默认 `1` |
59
32
 
60
33
  ```typescript
61
- interface $节点位置信息 {
62
- x: 数字; // x坐标
63
- y: 数字; // y坐标
64
- width: 数字; // 宽度
65
- height: 数字; // 高度
66
- centerX: 数字; // 中心点x坐标
67
- centerY: 数字; // 中心点y坐标
68
- }
34
+ const selector = $创建节点选择器();
35
+ const shallow = $创建节点选择器({ maxDepth: 15 });
36
+ const listPage = $创建节点选择器({ mode: 2 });
69
37
  ```
70
38
 
71
- #### $节点信息
39
+ ---
40
+
41
+ ## 节点信息
42
+
43
+ ### 位置 `$节点位置信息`
44
+
45
+ | 字段 | 说明 |
46
+ | --- | --- |
47
+ | `x` / `y` | 左上角 |
48
+ | `width` / `height` | 宽高 |
49
+ | `centerX` / `centerY` | 中心点 |
50
+
51
+ ### 节点 `$节点信息`
52
+
53
+ **属性**
54
+
55
+ | 字段 | 说明 |
56
+ | --- | --- |
57
+ | `id` | 节点 ID(内部定位用,不要改) |
58
+ | `identifier` | 控件标识符 |
59
+ | `label` | 标签文案 |
60
+ | `type` | 类型,如 `XCUIElementTypeButton` |
61
+ | `value` | 当前值 |
62
+ | `placeholderValue` | 输入框占位文字 |
63
+ | `title` | 标题 |
64
+ | `enabled` | 是否启用 |
65
+ | `bounds` | 位置大小 |
66
+ | `depth` | 层级 |
67
+ | `index` | 在父节点下的序号 |
68
+ | `parentId` | 父节点 ID |
69
+ | `childCount` | 子节点数量 |
70
+
71
+ **方法**
72
+
73
+ | 方法 | 说明 |
74
+ | --- | --- |
75
+ | `hittable()` | 当前是否可点击(可见且未被挡住) |
76
+ | `scrollToVisible()` | 滚动到可见区域 |
77
+ | `tap()` | 单击(不可见时会先尝试滚到可见) |
78
+ | `doubleTap()` | 双击 |
79
+ | `press(duration?)` | 长按,`duration` 单位毫秒,默认 500 |
80
+ | `点击中心()` | 点击中心坐标 |
81
+ | `点击随机范围()` | 在节点范围内随机点击 |
82
+ | `clearInput()` | 清空输入内容 |
83
+ | `input(text)` | 追加输入(不先清空) |
84
+ | `setValue(text)` | 设置值(见下方) |
85
+ | `parent()` | 父节点 |
86
+ | `child(index)` | 第 `index` 个子节点 |
87
+ | `allChildren()` | 全部子节点 |
88
+ | `siblings()` | 全部兄弟节点 |
89
+ | `previousSiblings()` | 前面的兄弟 |
90
+ | `nextSiblings()` | 后面的兄弟 |
91
+
92
+ ---
93
+
94
+ ## 选择器方法
95
+
96
+ ### 加载与结果
97
+
98
+ | 方法 | 说明 |
99
+ | --- | --- |
100
+ | `释放内存()` | 释放内存 |
101
+ | `加载节点数据(timeout?)` | 重新加载界面节点,默认超时 5000ms |
102
+ | `清除选择器()` | 清除已设置的筛选条件 |
103
+ | `xml(timeout?)` | 获取界面 XML,失败返回 `null` |
104
+ | `获取节点信息(timeout?)` | 获取所有匹配节点 |
105
+ | `获取一个节点信息(timeout?)` | 获取第一个匹配节点,没有则 `null` |
106
+
107
+ 超时单位均为毫秒,默认 `5000`。
72
108
 
73
109
  ```typescript
74
- interface $节点信息 {
75
- id: 字符串; // 节点ID
76
- identifier: 字符串; // 节点标识符
77
- label: 字符串; // 节点标签
78
- type: 字符串; // 节点类型
79
- value: 字符串; // 节点值
80
- placeholderValue: 字符串; // 节点占位符值
81
- title: 字符串; // 节点名称
82
- enabled: 布尔值; // 是否启用
83
- bounds: $节点位置信息; // 边界信息
84
- depth: 数字; // 层级深度
85
- index: 数字; // 索引
86
- parentId: 字符串; // 父节点ID
87
- childCount: 数字; // 子节点数量
88
-
89
- // 操作方法
90
- 点击中心(): 布尔值; // 点击中心
91
- 点击随机范围(): 布尔值; // 随机点击
92
- hittable(): 布尔值; // 节点是否可接收事件,用于判断节点是否在屏幕可见
93
- tap(): 布尔值; // 无障碍点击
94
- doubleTap(): 布尔值; // 无障碍双击
95
- press(duration: 数字): 布尔值; // 无障碍长按,duration 单位毫秒
96
- scrollToVisible(): 布尔值; // 将节点滚动到可见区域
97
- clearInput(): 布尔值; // 清空输入
98
- input(text: 字符串): 布尔值; // 追加输入(聚焦后输入)
99
- setValue(text: 字符串): 布尔值; // 设置节点的值(见下方支持控件)
100
- parent(): $节点信息 | null; // 获取父节点
101
- child(index: 数字): $节点信息 | null; // 获取子节点
102
- allChildren(): $节点信息[]; // 获取所有子节点
103
- siblings(): $节点信息[]; // 获取兄弟节点
104
- previousSiblings(): $节点信息[]; // 获取前面的兄弟节点
105
- nextSiblings(): $节点信息[]; // 获取后面的兄弟节点
106
- }
110
+ const selector = $创建节点选择器();
111
+ const nodes = selector.标签("确定").获取节点信息(5000);
112
+ const one = selector.获取一个节点信息(3000);
113
+ const xml = selector.xml();
114
+ selector.释放内存();
107
115
  ```
108
116
 
109
- ### 选择器方法
110
-
111
- #### 获取节点
117
+ ### 筛选条件
112
118
 
113
- ```typescript
114
- // 释放节点选择器占用的内存
115
- function 释放内存(): 无返回值;
119
+ 可链式调用,多个条件同时满足(并且关系)。
120
+ 带「匹配」的为模糊/正则匹配。
116
121
 
117
- // xml - 获取当前页面的 XML 字符串
118
- function xml(超时时间?: 数字): 字符串 | null;
122
+ **文本**
119
123
 
120
- // 获取多个节点
121
- function 获取所有节点(超时时间?: 数字): 数组<$节点信息>;
124
+ | 方法 | 说明 |
125
+ | --- | --- |
126
+ | `标签` / `标签匹配` | 标签 |
127
+ | `名称` / `名称匹配` | 标题 |
128
+ | `标识符` / `标识符匹配` | 标识符 |
129
+ | `值` / `值匹配` | 值 |
130
+ | `占位符` / `占位符匹配` | 占位文字 |
122
131
 
123
- // 获取单个节点
124
- function 获取一个节点(超时时间?: 数字): $节点信息 | null;
132
+ **类型与状态**
125
133
 
126
- // 加载节点数据
127
- function 加载节点数据(超时时间?: 数字): $节点选择器;
134
+ | 方法 | 说明 |
135
+ | --- | --- |
136
+ | `类型` / `类型匹配` | 类型,如 `XCUIElementTypeButton` |
137
+ | `是否启用` | 是否启用 |
128
138
 
129
- // 清除所有选择条件
130
- function 清除所有选择条件(): $节点选择器;
131
- ```
139
+ **位置与结构**
132
140
 
133
- **示例:**
141
+ | 方法 | 说明 |
142
+ | --- | --- |
143
+ | `索引` | 序号 |
144
+ | `层级` | 层级 |
145
+ | `子节点数量` | 子节点数,支持数字或如 `">0"` |
146
+ | `范围(x, y, width, height)` | 区域 |
147
+ | `xpath` | XPath |
148
+ | `id` | 按节点 ID |
134
149
 
135
150
  ```typescript
136
- const 选择器 = $创建节点选择器();
137
- // 获取所有匹配的节点
138
- const allNodes = 选择器.获取所有节点(5000);
139
- $打印信息日志(`找到 ${allNodes.length} 个节点`);
140
-
141
- // 获取第一个匹配的节点
142
- const 第一个节点 = 选择器.获取一个节点(3000);
143
- if (第一个节点) {
144
- $打印信息日志(`节点标签: ${第一个节点.label}`);
145
- }
146
-
147
- // 释放选择器内存
148
- 选择器.释放内存();
151
+ // 精确
152
+ selector.标签("确定").类型("XCUIElementTypeButton").获取一个节点信息(3000);
153
+
154
+ // 模糊
155
+ selector.标签匹配(".*登录.*").获取节点信息(3000);
156
+ selector.标识符匹配("^login_").获取节点信息(3000);
157
+
158
+ // 组合
159
+ selector
160
+ .类型("XCUIElementTypeTextField")
161
+ .是否启用(true)
162
+ .获取一个节点信息(3000);
149
163
  ```
150
164
 
151
- #### 条件筛选
152
-
153
- ##### 文本相关
154
-
155
- ```typescript
156
- // 精确匹配标签
157
- label(label: 字符串): $节点选择器
158
-
159
- // 标签模糊匹配
160
- labelMatch(match: 字符串): $节点选择器
161
-
162
- // 精确匹配名称
163
- title(title: 字符串): $节点选择器
164
-
165
- // 名称模糊匹配
166
- titleMatch(match: 字符串): $节点选择器
167
-
168
- // 精确匹配标识符
169
- identifier(identifier: 字符串): $节点选择器
165
+ 常见类型:`XCUIElementTypeButton`、`StaticText`、`TextField`、`SecureTextField`、`TextView`、`SearchField`、`Cell`、`Table`、`CollectionView`、`PickerWheel`、`Switch`、`Slider` 等。
170
166
 
171
- // 标识符模糊匹配
172
- identifierMatch(match: 字符串): $节点选择器
167
+ ---
173
168
 
174
- // 精确匹配值
175
- value(value: 字符串): $节点选择器
169
+ ## 节点操作说明
176
170
 
177
- // 值模糊匹配
178
- valueMatch(match: 字符串): $节点选择器
179
- ```
180
-
181
- **示例:**
171
+ ### 是否可点 / 滚到可见
182
172
 
183
173
  ```typescript
184
- const 选择器 = $创建节点选择器();
185
- // 查找标签为"确定"的按钮
186
- const confirmButton = 选择器.label("确定").获取一个节点(3000);
187
-
188
- // 查找包含"登录"的元素
189
- const loginElements = 选择器.labelMatch(".*登录.*").获取所有节点(3000);
190
-
191
- // 查找名称包含"button"的元素
192
- const buttons = 选择器.titleMatch("button").获取所有节点(3000);
193
-
194
- // 查找值为"submit"的元素
195
- const submitElement = 选择器.value("submit").获取一个节点(2000);
196
-
197
- // 通过标识符查找
198
- const 通过标识符 = 选择器.identifier("login_btn").获取一个节点(2000);
199
- const 标识符模糊 = 选择器.identifierMatch("^login_.*").获取所有节点(3000);
174
+ if (node.hittable()) {
175
+ node.tap();
176
+ } else {
177
+ node.scrollToVisible();
178
+ node.tap();
179
+ }
200
180
  ```
201
181
 
202
- // 释放选择器内存
203
- 选择器.释放内存();
182
+ - `hittable()`:当前能否点到
183
+ - `scrollToVisible()`:手动滚到可见
184
+ - `tap` / `doubleTap` / `press`:不可见时会自动尝试滚到可见再操作
204
185
 
205
- ##### 类型和属性
186
+ ### 点击
206
187
 
207
- ```typescript
208
- // 精确匹配类型
209
- type(type: string): $节点选择器
210
-
211
- // 类型模糊匹配
212
- typeMatch(match: string): $节点选择器
213
-
214
- // 启用状态
215
- enabled(enabled: boolean): $节点选择器
216
- ```
217
-
218
- **示例:**
188
+ | 方法 | 说明 |
189
+ | --- | --- |
190
+ | `tap()` | 推荐,单击 |
191
+ | `doubleTap()` | 双击 |
192
+ | `press(ms?)` | 长按,默认 500ms |
193
+ | `点击中心()` | 点中心坐标 |
194
+ | `点击随机范围()` | 范围内随机点 |
219
195
 
220
196
  ```typescript
221
- const 选择器 = $创建节点选择器();
222
- // 查找所有按钮
223
- const allButtons = 选择器.type("XCUIElementTypeButton").获取所有节点(3000);
224
-
225
- // 查找所有文本框
226
- const textFields = 选择器
227
- .typeMatch("XCUIElementTypeTextField")
228
- .获取所有节点(3000);
197
+ const btn = selector
198
+ .标签("确定")
199
+ .类型("XCUIElementTypeButton")
200
+ .获取一个节点信息(3000);
229
201
 
230
- // 查找启用的元素
231
- const enabledElements = 选择器.enabled(true).获取所有节点(3000);
232
-
233
- // 释放选择器内存
234
- 选择器.释放内存();
202
+ if (btn) {
203
+ btn.tap();
204
+ btn.doubleTap();
205
+ btn.press(800);
206
+ }
235
207
  ```
236
208
 
237
- ##### 位置和结构
209
+ ### 输入与设值
238
210
 
239
- ```typescript
240
- // 索引位置
241
- index(index: number): $节点选择器
211
+ | 方法 | 说明 |
212
+ | --- | --- |
213
+ | `clearInput()` | 清空 |
214
+ | `input(text)` | 追加输入,不清空原内容 |
215
+ | `setValue(text)` | 按控件类型设置 |
242
216
 
243
- // 层级深度
244
- depth(depth: number): $节点选择器
217
+ **`setValue` 行为**
245
218
 
246
- // 子节点数量
247
- childCount(childCount: number | string): $节点选择器
248
-
249
- // 边界范围
250
- bounds(x: number, y: number, width: number, height: number): $节点选择器
251
-
252
- // XPath 路径
253
- xpath(path: string): $节点选择器
254
- ```
219
+ | 控件类型 | 传参 | 效果 |
220
+ | --- | --- | --- |
221
+ | `PickerWheel` | 选项文案,如 `"1小时"` | 滚到该选项 |
222
+ | 文本框类(TextField 等) | 字符串 | 聚焦后追加输入,不先清空 |
255
223
 
256
- **示例:**
224
+ 覆盖原内容请先清空:
257
225
 
258
226
  ```typescript
259
- const 选择器 = $创建节点选择器();
260
- // 查找第一个元素
261
- const firstElement = 选择器.index(0).获取一个节点(2000);
262
-
263
- // 查找特定深度的元素
264
- const level3Elements = 选择器.depth(3).获取所有节点(3000);
265
-
266
- // 查找有子节点的元素
267
- const parentElements = 选择器.childCount(">0").获取所有节点(3000);
268
-
269
- // 查找特定区域的元素
270
- const regionElements = 选择器.bounds(100, 100, 200, 50).获取所有节点(3000);
271
-
272
- // 使用 XPath 查找
273
- const xpathElements = 选择器.xpath("//*[@title='快点JS']").获取所有节点(3000);
274
-
275
- // 释放选择器内存
276
- 选择器.释放内存();
227
+ field.clearInput();
228
+ field.setValue("hello");
277
229
  ```
278
230
 
279
- ### 节点操作
280
-
281
- #### 点击操作
282
-
283
231
  ```typescript
284
- // 点击节点中心(坐标点击)
285
- node.点击中心(): 布尔值;
286
-
287
- // 随机点击节点区域(坐标点击)
288
- node.点击随机范围(): 布尔值;
289
-
290
- // 节点是否可接收事件(用于判断是否显示在屏幕上)
291
- node.hittable(): 布尔值;
292
-
293
- // 无障碍点击
294
- node.tap(): 布尔值;
295
-
296
- // 无障碍双击
297
- node.doubleTap(): 布尔值;
298
-
299
- // 无障碍长按,duration 单位毫秒
300
- node.press(duration: 数字): 布尔值;
301
-
302
- // 将节点滚动到可见区域
303
- node.scrollToVisible(): 布尔值;
304
-
305
- // 清空输入
306
- node.clearInput(): 布尔值;
307
-
308
- // 追加输入
309
- node.input(text: 字符串): 布尔值;
310
-
311
- // 设置节点的值
312
- node.setValue(text: 字符串): 布尔值;
232
+ const wheel = selector.类型("XCUIElementTypePickerWheel").获取一个节点信息(3000);
233
+ if (wheel) {
234
+ wheel.setValue("1小时");
235
+ }
313
236
  ```
314
237
 
315
- #### tap / doubleTap / press - 无障碍手势
316
-
317
- 通过无障碍 API 直接操作节点,不依赖坐标点击。
318
-
319
- | 方法 | 参数 | 说明 |
320
- | --- | --- | --- |
321
- | `tap()` | 无 | 无障碍单击 |
322
- | `doubleTap()` | 无 | 无障碍双击 |
323
- | `press(duration)` | `duration`:长按持续时间,单位毫秒 | 无障碍长按 |
324
-
325
- **示例:**
238
+ ### 树导航
326
239
 
327
240
  ```typescript
328
- const 选择器 = $创建节点选择器();
329
-
330
- const btn = 选择器.label("确定").type("XCUIElementTypeButton").获取一个节点(3000);
331
- if (btn) {
332
- // 无障碍单击
333
- btn.tap();
334
-
335
- // 无障碍双击
336
- btn.doubleTap();
337
-
338
- // 无障碍长按 800ms
339
- btn.press(800);
241
+ const field = selector.类型("XCUIElementTypeTextField").获取一个节点信息(3000);
242
+ if (field) {
243
+ const parent = field.parent();
244
+ const children = parent?.allChildren() ?? [];
245
+ const prev = field.previousSiblings();
246
+ const next = field.nextSiblings();
247
+ const second = parent?.child(1);
340
248
  }
341
-
342
- // 释放选择器内存
343
- 选择器.释放内存();
344
249
  ```
345
250
 
346
- #### setValue - 设置节点的值
251
+ ---
347
252
 
348
- 按控件类型自动处理,常用支持如下:
253
+ ## 示例
349
254
 
350
- | 控件类型 | 传参示例 | 说明 |
351
- | --- | --- | --- |
352
- | `XCUIElementTypePickerWheel` | `"1小时"` | 滚轮选到对应选项文案 |
353
- | `XCUIElementTypeTextField` | `"hello"` | 先聚焦再输入文本 |
354
- | `XCUIElementTypeSecureTextField` | `"123456"` | 同上 |
355
- | `XCUIElementTypeTextView` | `"多行内容"` | 同上 |
356
- | `XCUIElementTypeSearchField` | `"关键词"` | 同上 |
255
+ ### 登录
357
256
 
358
- 文本类控件不会先清空已有内容;需要清空时先调用 `clearInput()`。
257
+ ```typescript
258
+ const selector = $创建节点选择器();
359
259
 
360
- **示例:**
260
+ try {
261
+ const user = selector.类型("XCUIElementTypeTextField").获取一个节点信息(5000);
262
+ if (user) {
263
+ user.clearInput();
264
+ user.setValue("demo_user");
265
+ }
361
266
 
362
- ```typescript
363
- const 选择器 = $创建节点选择器();
364
- // 查找并点击确定按钮
365
- const confirmBtn = 选择器
366
- .label("确定")
367
- .type("XCUIElementTypeButton")
368
- .获取一个节点(3000);
369
-
370
- if (confirmBtn) {
371
- const isHittable = confirmBtn.hittable();
372
- $打印信息日志(`是否可接收事件: ${isHittable}`);
373
-
374
- confirmBtn.scrollToVisible();
375
- // 优先使用无障碍点击;也可用 点击中心 / 点击随机范围 做坐标点击
376
- const clicked = confirmBtn.tap();
377
- if (clicked) {
378
- $打印信息日志("成功点击确定按钮");
267
+ const pass = selector
268
+ .清除选择器()
269
+ .类型("XCUIElementTypeSecureTextField")
270
+ .获取一个节点信息(3000);
271
+ if (pass) {
272
+ pass.clearInput();
273
+ pass.setValue("password");
379
274
  }
380
- }
381
275
 
382
- const field = 选择器.type("XCUIElementTypeTextField").获取一个节点(3000);
383
- if (field) {
384
- field.clearInput();
385
- field.setValue("hello");
276
+ const login = selector
277
+ .清除选择器()
278
+ .标签匹配(".*登录.*")
279
+ .类型("XCUIElementTypeButton")
280
+ .获取一个节点信息(3000);
281
+ if (login) {
282
+ login.tap();
283
+ }
284
+ } finally {
285
+ selector.释放内存();
386
286
  }
287
+ ```
387
288
 
388
- const wheel = 选择器.type("XCUIElementTypePickerWheel").获取一个节点(3000);
389
- if (wheel) {
390
- wheel.setValue("1小时");
391
- }
289
+ ### 列表里靠后的项
392
290
 
393
- // 随机点击避免检测
394
- const randomClick = confirmBtn?.点击随机范围();
395
- if (randomClick) {
396
- $打印信息日志("成功随机点击确定按钮");
291
+ ```typescript
292
+ const selector = $创建节点选择器({ mode: 2 });
293
+ const item = selector.标签("第 30 项").获取一个节点信息(5000);
294
+ if (item) {
295
+ item.tap(); // 不在可见区域时会自动滚动
397
296
  }
398
-
399
- // 释放选择器内存
400
- 选择器.释放内存();
297
+ selector.释放内存();
401
298
  ```
402
299
 
403
- #### 节点导航
300
+ ### 查看界面结构
404
301
 
405
302
  ```typescript
406
- // 获取父节点
407
- node.parent(): $节点信息 | null
408
-
409
- // 获取指定索引的子节点
410
- node.child(index: number): $节点信息 | null
411
-
412
- // 获取所有子节点
413
- node.allChildren(): $节点信息[]
303
+ const selector = $创建节点选择器();
304
+ const xml = selector.xml(8000);
305
+ if (xml) {
306
+ $打印信息日志(xml);
307
+ }
308
+ selector.释放内存();
309
+ ```
414
310
 
415
- // 获取兄弟节点
416
- node.siblings(): $节点信息[]
311
+ ---
417
312
 
418
- // 获取前面的兄弟节点
419
- node.previousSiblings(): $节点信息[]
313
+ ## 常见问题
420
314
 
421
- // 获取后面的兄弟节点
422
- node.nextSiblings(): $节点信息[]
423
- ```
315
+ **找不到节点**
316
+ 加大超时;减少条件或改用匹配;换 `mode`;用 `xml()` 看实际文案和类型。
424
317
 
425
- **示例:**
318
+ **点了没反应**
319
+ 先看 `hittable()`;确认点到的是目标控件;可对比 `点击中心()`。
426
320
 
427
- ```typescript
428
- const 选择器 = $创建节点选择器();
429
- // 查找输入框并获取其父容器
430
- const textField = 选择器.type("XCUIElementTypeTextField").获取一个节点(3000);
431
-
432
- if (textField) {
433
- const container = textField.parent();
434
- if (container) {
435
- $打印信息日志(`容器类型: ${container.type}`);
436
-
437
- // 获取容器的所有子元素
438
- const siblings = container.allChildren();
439
- $打印信息日志(`容器包含 ${siblings.length} 个子元素`);
440
-
441
- // 查找同级的按钮
442
- const siblingButtons = siblings.filter(
443
- (node) => node.type === "XCUIElementTypeButton",
444
- );
445
- }
446
- }
321
+ **输入叠在旧文字后面**
322
+ `input` / 文本类 `setValue` 是追加,先 `clearInput()`。
447
323
 
448
- // 释放选择器内存
449
- 选择器.释放内存();
450
- ```
324
+ **滚轮设不中**
325
+ `setValue` 要传界面上显示的选项文案;确认类型是 `PickerWheel`;多列时选对那一列。