# How to use UiSelector to find an element based on siblings?

**URL:** <https://discuss.appium.io/t/how-to-use-uiselector-to-find-an-element-based-on-siblings/28386>\
**Category:** Support\
**Created:** [October 24, 2019, 11:33am UTC](https://discuss.appium.io/t/how-to-use-uiselector-to-find-an-element-based-on-siblings/28386 "2019-10-24T11:33:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![QAthulhu](https://discuss.appium.io/letter_avatar_proxy/v4/letter/q/e47c2d/32.png) [@QAthulhu](https://discuss.appium.io/u/QAthulhu)\
**Post date:** [October 24, 2019, 11:33am UTC](https://discuss.appium.io/t/how-to-use-uiselector-to-find-an-element-based-on-siblings/28386/1 "2019-10-24T11:33:35Z")

</div>

I’m trying to get a scrollable/recyclerview but it has no unique ID, and I must get the value of it’s sibling to find it. Here’s how it looks:

```
`LinearLayout`
    `TextView ("Group Name")`
    `RecyclerView`
        `TextView("Item")`

```

I can find the scrollable just fine by hardcoding an index like this:  
`String uiScrollable = "new UiScrollable(new UiSelector().resourceId(\"recyclerID\").instance(1)).setAsHorizontalList().scrollTextIntoView(\"Item\")";`  
`MobileElement element = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator(uiScrollable));`

But I need it to not use an index and find it based on the “Group Name”. I tried fromParent and childSelector but keep getting NoSuchElementException.

`String uiScrollable = "new UiScrollable(new UiSelector().resourceId(\"recyclerID\").fromParent(new UiSelector().childSelector(new UiSelector().text(\"Group Name\")))).setAsHorizontalList().scrollTextIntoView(\"Item\")";`  
also  
`String uiScrollable = "new UiScrollable(new UiSelector().text(\"Group Name\").fromParent(new UiSelector().className(\"android.widget.LinearLayout\")).childSelector(new UiSelector().resourceId(\"recyclerID\")))`
