iOS UIATableCell children switch path order in XML when out of view 1.3.7
iOS8.x iPhone6 sim

Curious if anyone else has encountered this.

I have a UIATableView with a dynamic number of UIATableCell. Each UIATableCell has exactly three UIAStaticText.

for cell in table:
    title = cell.find_elements_by_class_name("UIAStaticText")[0].get_attribute("name")
    description = cell.find_elements_by_class_name("UIAStaticText")[1].get_attribute("name")
    date = cell.find_elements_by_class_name("UIAStaticText")[2].get_attribute("name")

This works perfectly until the UIATableCell is physically out of view. At that point the description and date elements flip positions in the XML for some unknown reason. That obviously breaks the above logic.

I can code workarounds, the name is also the UIATableCell “name” attribute, I can find dates by comparing to a date mask, and then the leftover is the description. Or something like that.

I’m more curious if anyone’s encountered this and if there’s some explanation I can add to my education. :slight_smile:

SOLUTION: Scroll UIATableCell into view, then get it’s value fresh.

    for i in range(1, num_cells):
        cell = self.driver.find_elements_by_class_name("UIATableCell")[i]
        # Have to scroll cell into view or order of UIAStaticText gets mangled which breaks data extraction logic
        if cell.is_displayed() is False:
            self.driver.execute_script("mobile: scrollTo", {"element":})
        # Now that the cell is in view, poll the XML fresh to extract the data
        date = cell.find_elements_by_class_name("UIAStaticText")[2].get_attribute("name")