---
title: "onAncestors"
description: "Returns all the ancestors of this node.

 For the following tree

```
|-A |-B   |-C <- this node
Returns B, A
```"
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
@CheckResult
fun SemanticsNodeInteraction.onAncestors(): SemanticsNodeInteractionCollection
```


Returns all the ancestors of this node.

 For the following tree

```
|-A |-B   |-C <- this node
Returns B, A
```



