How to capture a CardView element in Appium

I need to capture an element in my automated tests with Appium in android, this element is of type CardView CardView  |  Android Developers and I can’t capture it in the Appium Inspector how could I capture it?

I tried using the following selector:

//androidx.cardview.widget.CardView[1]

You can see the component tree here:

for example

// Java
WebElement el = driver.findElement(AppiumBy.className("className = \"androidx.cardview.widget.CardView\""));
1 Like

This didn’t really work for me, I tried in the inspector and in my script and I could not find the element

Ok. Print output of page source. And check you can find your element there.

I tried that and I didn’t see any element that has this class CardView :smiling_face_with_tear:

Look more for text values near. They should help you to find needed element.