Find all elements under recyclerView of type relativeLayout

Hi Guys !!

I’m finding it difficult to find all elements of type “relativeLayout” under “android.support.v7.widget.RecyclerView”

Please find the sample UiAutomator screenshot for reference.

Any suggestions would be highly helpful to me.

Didn’t test anything, but something like:

List<WebElement> elements = driver.findElementById("recycler_view_catalog_fragment").findElements(By.className("android.widget.RelativeLayout"));

Hey ! Thanks for the immediate reply.

instead of 4 relative-Layouts I see 16 relative-layouts as the children of these relative-layouts also have been included. How can I get exactly these 4 relative layouts ie the children of recycler_catalog_view_fragment shown in screenshot ?

If you can observe in this screenshot - I see 3 relativelayout children for each prior relative layout totally 12 + earlier 4 i.e 16 in total (size)

try xpath. Again didn not test anything of the following :smiley: so just check for errors and keep trying:

driver.findElementsByXPath("//android.support.v7.widget.RecyclerView[0]/android.widget.RelativeLayout")

Thanks !!! Was able to figure it out :slight_smile:

Is there a similar way to do this in Ruby?

@Karthik_Sriharsha, can you please help me, i am stuck in finding all the elements inside recycler view
Thanks!