How to choose the element in the second item of list

as the picture ,I want to get the textview in the second item of list.(Python)

chooseForum=testMethod.commonCls.driver.find_elements_by_xpath("//div[@id=‘game_information’]//TextView[@id=‘title’]")[0].text

this sentence can not pick out the seconde item,so I don’t know how to do.

If you can get the parent element, i.e. the one that is highlighted in your image, you could use it to focus your search.

element.find_elements_by_class('android.widget.TextView)[1]

Why not //android.widget.ListView/*[1]/android.widget.RelativeLayout/android.widget.TextView? This should select the TextView in the item under your application’s ‘B’ section.

If I studied my Xpath correctly, Xpath child nodes are indexed starting from 1, and not 0 (I’d like if someone can either confirm that or reject that for me).

1 Like

the error of element.find_elements_by_class

thank you for your //android.widget.ListView/*[1]/android.widget.RelativeLayout/android.widget.TextView