.

Appium iOS : How to find child element of an element

Appium : 1.3.1
Mac OS X 10.9.4

I face a scenario where I need to iterate a loop through all the results and click on 1 of them if the text matches.

As per hierarchy the structure looks like this

  >UIATableView
     > UIATableCell
            >UIAStaticText
     > UIATableCell
            >UIAStaticText
     > UIATableCell
            >UIAStaticText
     > UIATableCell
            >UIAStaticText
 
Click action works fine if I take List as UIATableCell.

I took list listingResults as @iOSFindBy(className="UIATableCell")

  for (WebElement resultNum : listingResults) {

    resultText= resultNum.getText().trim();

    if(!resultText.contains("more option")){
        System.out.println(resultText);
     }

  }

resultNum.getText() is not returning any text. And for text I need to look into "UIAStaticText".

I'm trying to use findelement and expecting resultNum.findelement(By.className("UIAStaticText")).getText() to return the text. It is not working...




Solution:

   

I finally got the answer here:

https://github.com/appium/appium/issues/2814

As per jlipps comment:

Sometimes the text is indeed ''. Did you also try getAttribute('label'), getAttribute('value'), and getAttribute('name')?

And getAttribute('name') worked in my case
 

Recent Posts