Search code examples
automationappiumappium-androidpython-appium

how to select textView without id in appium?


I'm new to automation and appium
so I'm trying to automate sololearn
I have such a list of relativeLayouts each one contains a follower picture, name, and lvl. here is an image for more details
https://drive.google.com/file/d/1VIeK3tPmzv_crEX0DQ68UH9a3cUTKNlD/view?usp=sharing
I was able to select those relativeLayouts in a list by doing this

followersList = driver.find_elements_by_id("com.sololearn:id/facebook_friends_view_layout")

which gives me this list: [<appium.webdriver.webelement.WebElement (session="33b98510-b0e1-45bd-af6c-9ca830e938fe", element="92ebaa8f-321e-4897-9f5b-df6cc38afc8e")> , <appium.webdriver.webelement.WebElement (session="33b98510-b0e1-45bd-af6c-9ca830e938fe", element="d21e273f-db0c-4d4d-8937-dbc52b437c99")>]

Can I now extract the textView that contains the names of followers from that list? idk I lack knowladge but I'm comparing it to js and html where you can get first children of elements and things like that. Can i do that here? is there any other possible ways?

I don't want to use xpaths , and the name elements doesn't have and id so I can't select it with it's id.
my goal is to get all followers names in a table.
Help please, and thanks <3


Solution

  • Got it this is my solution

    followersList = driver.find_elements_by_id("com.sololearn:id/facebook_friends_view_layout")
    for follower in followersList:
       followerName = follower.find_element_by_id("com.sololearn:id/user_name")
       print(followerName.text)