How to get a List text from class "android.widget.TextView" in Android layout

Assume I have many part “android.widget.TextView” on my Android layout.
Can I get a list Text from all part “android.widget.TextView”.
I try use find find_element_by_xpath, but it must to define a text detail text-param
element = driver.find_element_by_xpath("//android.widget.TextView[@text=‘abc’]")

Another, I also try use find_element_by_class_name:
element = driver.find_element_by_class_name(‘android.widget.TextView’)
But it return a WebElement.

Are there the ways get list Text from all part “android.widget.TextView” in a layout?
Thank you!

items = driver.find_elements_by_class_name(“android.widget.TextView”)

or with xpath

items = driver.find_elements_by_xpath("//*[@class=‘android.widget.TextView’]")

there’s plenty of explanations for something as rudimentary as this in the docs

1 Like