# Tìm phần tử

Bạn có thể thực hiện các thao tác sau với nút hiện tại:

1. Tìm các phần tử cây hiển thị trên trang hiện tại, sau đó nhấp vào phần tử thông qua nút [Tap Element](/vi/rparobotic-process-automation/03-node/01-simulation-operations/04-tap-element)
2. Tìm các phần tử cây hiển thị cụ thể, sau đó lấy thuộc tính của phần tử thông qua nút [Run JS Script](/vi/rparobotic-process-automation/03-node/02-data-processing/01-run-js-script)
3. Tìm các phần tử cây hiển thị cụ thể, sau đó kiểm tra xem phần tử có tồn tại hay không thông qua đầu ra của nút hiện tại, tương tự như việc in nhật ký trong gỡ lỗi in


[What is a view tree?](/vi/rparobotic-process-automation/05-appendix/02-what-is-a-view-tree)

## Tham số

- **Loại bộ chọn** Menu thả xuống
- Theo Tìm phần tử
- Sử dụng phần tử trước đó


Nếu Khi chọn "Tìm phần tử", bạn có thể lọc các phần tử thông qua các điều kiện nút DOM sau. Các phần tử khớp với các điều kiện thuộc tính bạn đặt sẽ được trình thực thi lọc ra.

- Bạn có thể thêm các điều kiện bắt buộc trong **[Khi điều kiện được đáp ứng]**. Hỗ trợ 4 điều kiện sau, với tối đa 4 bộ lọc song song được hỗ trợ đồng thời:
- văn bản
- fullId
- lớp
- mô tả


Bạn có thể lấy các thuộc tính phần tử của màn hình điện thoại đám mây hiện tại thông qua công cụ dành cho nhà phát triển.

- **[Khi có nhiều đối tượng khớp trên trang]**
- Lấy một phần tử
- **[Chọn phần tử nào?]**
- Khi chọn "Lấy một phần tử", tùy chọn này sẽ xuất hiện. Bạn có thể nhập số chỉ mục tương ứng, ví dụ, nhập số 1 có nghĩa là bạn sẽ lấy phần tử khớp đầu tiên
- Lấy danh sách phần tử


"Sử dụng phần tử trước đó": Khớp trực tiếp với nút DOM của phần tử trong quá trình thực thi thực tế. Chức năng này thường được sử dụng với nút "Tìm phần tử".

- **Thời gian chờ tối đa để phần tử xuất hiện**
- Sau khi điền số, trình tìm kiếm hiện tại sẽ liên tục kiểm tra phần tử bạn cần tìm. Quá trình thực thi tiếp tục sau khi tìm thấy phần tử. Nếu không tìm thấy phần tử trong thời gian này, nút tiếp theo sẽ bắt đầu thực thi.
- Có thể điền hoặc tham chiếu một số, đơn vị là mili giây.
- **[Độ trễ sau khi tìm thấy phần tử]**


## Kết quả đầu ra

- **Tham số đầu ra**
- Phần tử: Đầu ra ở định dạng nút (thực chất là JSON). Bạn có thể phân tích nội dung trong phần tử trực tiếp bằng cách thực thi "Chạy tập lệnh JS".
- **Nhật ký thực thi**
- Thời gian bắt đầu
- Thời gian kết thúc
- Thời lượng (ms)
- Trạng thái (Thành công/Thất bại)


## Ví dụ

1. Trên trang danh sách ứng dụng của hệ thống Android, bạn có thể xuất phần tử DOM của mỗi ứng dụng thông qua nút Tìm phần tử. Trong bước tiếp theo, bạn có thể lặp qua phần tử DOM của mỗi ứng dụng thông qua nút Vòng lặp, sau đó kiểm tra tên của mỗi ứng dụng thông qua nút Chạy tập lệnh JS.


#### Cấu hình:

| Tên trường | Giá trị trường |

| -------------------------------------------------------- | ----------------------------------------------- |

| **Khi điều kiện được đáp ứng** | "fullID" bằng "com.android.launcher3:id/icon" |

| **Khi có nhiều đối tượng khớp trên trang** | Lấy danh sách phần tử |

| **Thời gian chờ phần tử xuất hiện** | 3000 |

| **Độ trễ sau khi tìm thấy phần tử** | 0 |

### Kết quả:

##### Tham số đầu ra

"**Danh sách phần tử**" là một danh sách với giá trị:

details
summary
Nhấp để mở rộng/thu gọn
```json
    [ { "isScrollable": false, "centerX": 135, "uuid": "1b03ee9a-91bd-457f-9981-7f2bfba0905b", "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "index": 0, "isCheckable": false, "childCount": 0, "bounds": { "top": 261, "right": 270, "left": 0, "bottom": 621 }, "packageName": "com.android.launcher3", "isSelected": false, "isFocusable": true, "isPassword": false, "contentDescription": "Calendar", "isClickable": true, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "centerY": 441, "text": "Calendar", "isVisibleToUser": true }, { "isScrollable": false, "text": "Chrome", "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "index": 1, "isCheckable": false, "uuid": "6446a15a-47e9-4ee3-adcd-8f63197653d4", "childCount": 0, "contentDescription": "Chrome", "packageName": "com.android.launcher3", "isSelected": false, "bounds": { "top": 261, "right": 540, "bottom": 621, "left": 270 }, "centerX": 405, "isFocusable": true, "isPassword": false, "isClickable": true, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "centerY": 441, "isVisibleToUser": true }, { "isScrollable": false, "centerX": 675, "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "uuid": "d5ae8607-be23-4166-a332-32911dc5eae0", "isCheckable": false, "childCount": 0, "index": 2, "packageName": "com.android.launcher3", "isSelected": false, "isFocusable": true, "isPassword": false, "isClickable": true, "text": "Clock", "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "contentDescription": "Clock", "centerY": 441, "bounds": { "right": 810, "top": 261, "left": 540, "bottom": 621 }, "isVisibleToUser": true }, { "isScrollable": false, "contentDescription": "Contacts", "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "isCheckable": false, "index": 3, "childCount": 0, "packageName": "com.android.launcher3", "isSelected": false, "text": "Contacts", "isFocusable": true, "isPassword": false, "centerX": 945, "uuid": "6f920c6c-221c-425c-b5b1-d438b1fc7fe9", "isClickable": true, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "centerY": 441, "bounds": { "top": 261, "right": 1080, "bottom": 621, "left": 810 }, "isVisibleToUser": true }, { "isScrollable": false, "centerX": 135, "centerY": 801, "bounds": { "bottom": 981, "right": 270, "left": 0, "top": 621 }, "isLongClickable": true, "text": "Files", "resourceId": "com.android.launcher3:id/icon", "contentDescription": "Files", "isCheckable": false, "childCount": 0, "packageName": "com.android.launcher3", "index": 4, "isSelected": false, "isFocusable": true, "isPassword": false, "isClickable": true, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "uuid": "3e8b09e7-4948-4132-9ca8-0ca57cf5a12d", "isVisibleToUser": true }, { "isScrollable": false, "contentDescription": "Gallery", "centerY": 801, "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "isCheckable": false, "childCount": 0, "index": 5, "text": "Gallery", "packageName": "com.android.launcher3", "isSelected": false, "centerX": 405, "isFocusable": true, "isPassword": false, "isClickable": true, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "uuid": "7b1b7b09-3ca0-422d-b35a-37ce26e2517b", "isVisibleToUser": true, "bounds": { "bottom": 981, "right": 540, "top": 621, "left": 270 } }, { "isScrollable": false, "centerY": 801, "centerX": 675, "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "isCheckable": false, "childCount": 0, "packageName": "com.android.launcher3", "isSelected": false, "bounds": { "right": 810, "bottom": 981, "top": 621, "left": 540 }, "index": 6, "contentDescription": "Gmail", "uuid": "9b8815b9-1079-4969-bf77-c3b27e4656f0", "isFocusable": true, "isPassword": false, "isClickable": true, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "isVisibleToUser": true, "text": "Gmail" }, { "isScrollable": false, "text": "Instagram", "centerY": 801, "uuid": "045888d5-9154-4a2a-b6da-649f6c54e9da", "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "bounds": { "bottom": 981, "right": 1080, "top": 621, "left": 810 }, "isCheckable": false, "childCount": 0, "contentDescription": "Instagram", "packageName": "com.android.launcher3", "isSelected": false, "index": 7, "isFocusable": true, "isPassword": false, "centerX": 945, "isClickable": true, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "isVisibleToUser": true }, { "isScrollable": false, "index": 8, "uuid": "4ad6d1e9-02a4-4163-968b-b764968a2e1b", "centerX": 135, "text": "Messaging", "isLongClickable": true, "bounds": { "top": 981, "right": 270, "left": 0, "bottom": 1341 }, "resourceId": "com.android.launcher3:id/icon", "isCheckable": false, "childCount": 0, "centerY": 1161, "contentDescription": "Messaging", "packageName": "com.android.launcher3", "isSelected": false, "isFocusable": true, "isPassword": false, "isClickable": true, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "isVisibleToUser": true }, { "isScrollable": false, "index": 9, "text": "MoreLogin Bot", "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "isCheckable": false, "childCount": 0, "centerY": 1161, "packageName": "com.android.launcher3", "isSelected": false, "contentDescription": "MoreLogin Bot", "centerX": 405, "isFocusable": true, "isPassword": false, "isClickable": true, "uuid": "fa990303-fa24-4c27-bc1b-32dec1d15fc7", "bounds": { "top": 981, "right": 540, "bottom": 1341, "left": 270 }, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "isVisibleToUser": true }, { "isScrollable": false, "index": 10, "bounds": { "right": 810, "top": 981, "left": 540, "bottom": 1341 }, "centerX": 675, "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "isCheckable": false, "childCount": 0, "centerY": 1161, "packageName": "com.android.launcher3", "isSelected": false, "isFocusable": true, "isPassword": false, "isClickable": true, "contentDescription": "Open Camera", "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "text": "Open Camera", "uuid": "55fd0ae2-cb1b-44f9-93af-91064aaebea2", "isVisibleToUser": true }, { "isScrollable": false, "index": 11, "contentDescription": "Phone", "bounds": { "top": 981, "right": 1080, "bottom": 1341, "left": 810 }, "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "uuid": "355737cc-e262-4c9a-872a-79ce9ff01bdd", "isCheckable": false, "childCount": 0, "centerY": 1161, "packageName": "com.android.launcher3", "isSelected": false, "text": "Phone", "isFocusable": true, "isPassword": false, "centerX": 945, "isClickable": true, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "isVisibleToUser": true }, { "isScrollable": false, "centerX": 135, "index": 12, "uuid": "dec9c272-397c-4395-8985-e2e583d5a567", "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "isCheckable": false, "childCount": 0, "packageName": "com.android.launcher3", "isSelected": false, "isFocusable": true, "isPassword": false, "centerY": 1521, "isClickable": true, "text": "Play Store", "bounds": { "bottom": 1701, "right": 270, "left": 0, "top": 1341 }, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "contentDescription": "Play Store", "isVisibleToUser": true }, { "isScrollable": false, "contentDescription": "Search", "index": 13, "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "isCheckable": false, "bounds": { "bottom": 1701, "right": 540, "top": 1341, "left": 270 }, "childCount": 0, "text": "Search", "packageName": "com.android.launcher3", "isSelected": false, "centerX": 405, "isFocusable": true, "isPassword": false, "centerY": 1521, "isClickable": true, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "isVisibleToUser": true, "uuid": "5c96c836-ea08-49a8-809b-10e7efb218de" }, { "isScrollable": false, "uuid": "aaf1f6f6-109f-4b28-b0f4-1206f2fbeabc", "text": "Settings", "centerX": 675, "isLongClickable": true, "index": 14, "resourceId": "com.android.launcher3:id/icon", "isCheckable": false, "childCount": 0, "contentDescription": "Settings", "packageName": "com.android.launcher3", "isSelected": false, "isFocusable": true, "isPassword": false, "centerY": 1521, "isClickable": true, "bounds": { "right": 810, "bottom": 1701, "top": 1341, "left": 540 }, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "isVisibleToUser": true } ]
```

br
1. Trên trang danh sách ứng dụng của hệ thống Android, bạn có thể hiển thị giá trị của phần tử DOM thứ 2 trong danh sách các phần tử khớp với điều kiện thông qua nút Tìm phần tử. Phần tử này có thể được nhấp chuột thông qua nút Chạm vào phần tử.


#### Cấu hình:

| Tên trường | Giá trị trường |

| -------------------------------------------------------- | ---------------------------------------------- |

| **Khi điều kiện được đáp ứng** | "fullID bằng "com.android.launcher3:id/icon" |

| **Khi có nhiều đối tượng khớp trên trang** | "Lấy một phần tử duy nhất" |

| **Chọn phần tử nào?** | "2" |

| **Thời gian chờ phần tử xuất hiện** | "3000" |

| **Độ trễ sau khi tìm thấy phần tử** | "0" |

#### Kết quả:

##### Tham số đầu ra

"**Element**" là một đối tượng phần tử (JSON) với giá trị:

details
summary
Nhấp để mở rộng/thu gọn
```json
    { "isScrollable": false, "text": "Chrome", "bounds": { "top": 261, "right": 540, "bottom": 621, "left": 270 }, "isLongClickable": true, "resourceId": "com.android.launcher3:id/icon", "index": 1, "isCheckable": false, "childCount": 0, "contentDescription": "Chrome", "packageName": "com.android.launcher3", "isSelected": false, "centerX": 405, "isFocusable": true, "isPassword": false, "isClickable": true, "isChecked": false, "isFocused": false, "isEnabled": true, "className": "android.widget.TextView", "centerY": 441, "isVisibleToUser": true, "uuid": "4aa1242a-daa8-46dd-8bf4-f100f3cf228a" }
```

Bạn có thể thấy giá trị contentDescription là "Chrome". Ở bước tiếp theo, bạn có thể nhấp vào phần tử này thông qua nút [Tap Element](/vi/rparobotic-process-automation/03-node/01-simulation-operations/04-tap-element).

## Các nút liên quan

- [Tap Element](/vi/rparobotic-process-automation/03-node/01-simulation-operations/04-tap-element)
- [Run JS Script](/vi/rparobotic-process-automation/03-node/02-data-processing/01-run-js-script)