Many findElement in a row with xPath

Here is the screenshot of my app’s tree :

Apps tree

I have a methode to get all of the TableCell. But how can I find the childs of my WebElements ?

I’ve tried this :

getMyTableCell().get(0).findElements(By.xpath".//*")

But this expression give me the UIAApplication (root). The .//* seems to search the elements from the root.

Any idea ?

You cannot currently find children elements using xpath, that does not work in Appium last I knew. See this bug report: https://github.com/appium/appium/issues/6227

Here is how I obtain all UIATableCell children of a UIATable using Python. Find my Table using xpath, then the children using class_name (or something other than xpath).

        table = self.driver.find_element_by_xpath(table_xpath)
        cells = table.find_elements_by_class_name('UIATableCell')

Try xpath axes
Also you can configure xpath of WebElement using xpath syntax

I get children of web element by using following logics:

  1. String xpath = parentXpath + “/descendant::*”;
    appiumDriver.findElements(By.xpath(xpath));

  2. String xpath = parentXpath + “/child::*”;
    appiumDriver.findElements(By.xpath(xpath));

‘parentXpath’ it is xpath to your WebElement

What if we pulled the XML page source, and then performed relative Xpath searches on the page source stored in the test client’s memory rather than have Appium handle all of it? Would this be a decent workaround?

After many search, it seems that this method could not works (bug : https://github.com/goto100/xpath/issues/45)…

I’ve done a custom solution :

String selector = “//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[” + (index + 2) + “]/UIAButton[1]”;
findElement(By.xpath(selector));

As many times in computer history -> “it works, it’s worth” :stuck_out_tongue:

Thanks for your help !