# What is a View Tree?

A **view tree** (also known as a UI hierarchy or DOM tree) is a structured representation of all the visual elements currently displayed on an Android device's screen. It is the foundation for how MoreLogin RPA locates and interacts with on-screen elements.

## How It Works

When an Android app renders its UI, the system creates a hierarchical tree of **View** objects. Each node in this tree represents a UI element — buttons, text fields, images, containers, etc.

```
FrameLayout
├── LinearLayout
│   ├── TextView ("Welcome")
│   └── EditText (input field)
├── RecyclerView
│   ├── ViewHolder[0]
│   │   ├── ImageView (app icon)
│   │   └── TextView ("Chrome")
│   └── ViewHolder[1]
│       ├── ImageView (app icon)
│       └── TextView ("Gmail")
└── FrameLayout
    └── Button ("OK")
```

MoreLogin RPA uses the **Android Accessibility Service** to capture this tree, converting it into a JSON structure that your workflow can query.

## Element Properties

Each element in the view tree exposes these key properties:

| Property | Type | Description | Example |
|  --- | --- | --- | --- |
| `text` | String | Visible text displayed by the element | `"Chrome"` |
| `resourceId` | String | Android resource ID (also called `fullId`) | `"com.android.launcher3:id/icon"` |
| `className` | String | Android view class name | `"android.widget.TextView"` |
| `contentDescription` | String | Accessibility description (used for screen readers) | `"Chrome"` |
| `packageName` | String | Package name of the app owning this element | `"com.android.launcher3"` |
| `bounds` | Object | Screen coordinates `{top, right, bottom, left}` | `{"top":261,"right":540,...}` |
| `centerX` / `centerY` | Integer | Center point coordinates of the element | `405`, `441` |
| `isClickable` | Boolean | Whether the element responds to tap events | `true` |
| `isEnabled` | Boolean | Whether the element is interactive | `true` |
| `isVisibleToUser` | Boolean | Whether the element is currently visible on screen | `true` |
| `childCount` | Integer | Number of child elements | `0` |
| `index` | Integer | Position index among sibling elements | `2` |


## How RPA Uses the View Tree

### Finding Elements

The [Find Element](/rparobotic-process-automation/03-node/01-simulation-operations/03-find-element) node queries the view tree using filter conditions:

| Filter Condition | Description | Example |
|  --- | --- | --- |
| `text` | Match by visible text | `text` Equals `"Chrome"` |
| `fullId` | Match by resource ID | `fullId` Equals `"com.android.launcher3:id/icon"` |
| `class` | Match by view class | `class` Equals `"android.widget.Button"` |
| `desc` | Match by content description | `desc` Contains `"Search"` |


### Interacting with Elements

Once an element is found, you can:

1. **Tap it** — using the [Tap Element](/rparobotic-process-automation/03-node/01-simulation-operations/04-tap-element) node
2. **Extract data** — using the [Run JS Script](/rparobotic-process-automation/03-node/02-data-processing/01-run-js-script) node to read properties like `text` or `contentDescription`
3. **Loop over multiple elements** — using the [Loop](/rparobotic-process-automation/03-node/03-flow-logic/02-loop) node to iterate through a list of found elements


## Inspecting the View Tree

Use the **Developer Tools** in MoreLogin RPA to inspect the view tree of any cloud phone screen in real time:

1. Open the cloud phone in MoreLogin
2. Go to **RPA → Developer Tools**
3. The view tree panel shows all elements on the current screen
4. Click any element to see its properties (text, resourceId, bounds, etc.)


For more about Developer Tools, see [Developer Tools](/rparobotic-process-automation/02-using-rpa/04-developer-tools).

## Tips

- **Use `resourceId` for stable matching**: Text content may change across languages or app updates, but `resourceId` values are usually stable.
- **Combine multiple conditions**: Use `text` + `class` together when `resourceId` is not available.
- **Check `isVisibleToUser`**: Elements may exist in the tree but be off-screen. The Find Element node only returns visible elements by default.
- **Wait for elements**: Screens may take time to load. Use the **Maximum Wait Time** parameter in Find Element to poll until the element appears.


## Related

- [Find Element](/rparobotic-process-automation/03-node/01-simulation-operations/03-find-element)
- [Tap Element](/rparobotic-process-automation/03-node/01-simulation-operations/04-tap-element)
- [Developer Tools](/rparobotic-process-automation/02-using-rpa/04-developer-tools)
- [Supported Field Types](/rparobotic-process-automation/05-appendix/01-supported-field-types)