iOS Indexes are not in the correct order

We recently have been expanding our test coverage to cover both android and iOS with the intention that the tests with little intervention should be able to run on both. Unfortunately, when using a list of items and retrieving values off that list with await driver.waitForElementsByAccessibilityId(elName); I’m finding that the iOS returns are very different than those on Android. Generally, Android returns indexes correctly- from top to bottom. I’ve found that in lists with two iOS is reversing them and on lists of three or more it’s disorganized altogether.

For instance, if I had a list of fruits:

And on my list I have three:
fruits=[apples, oranges, cherries]

And I do const fruitOrder = await driver.waitForElementsByAccessibilityId(fruits);

And then verify the order of the elements I would expect:

 expect(await fruits[0].text())"apples");
 expect(await fruits[1].text())"oranges");
 expect(await fruits[2].text())"cherries");

This IS CORRECT on Android but instead returns this way for iOS:

 expect(await amounts[0].text())"oranges");
 expect(await amounts[1].text())"apples");
 expect(await amounts[2].text())"cherries");

Is this a known issue/difference with iOS? Aside from applying an index directly to the accessibility label and accessing the element that way is there another way to address this? I’ve not seen a report directly of this and would be interested to know if anyone has experienced this/something similar.

Elements lookup and ordering is done by xctest. There is nothing we can change there. XCTest itself, though provides two options for elements bounding: by index and by accessibility id. By default WDA uses the latter, but it is possible to try bounding by index by assigning boundElementsByIndex setting to true.

Thank you! I will definitely look into that- I’ve not come across boundElementsByIndex :slight_smile:

Hi @mykola-mokhnach-
looking into this on friday- there’s really very limited info/docs on boundElementsByIndex. I wrongly assumed this was some type of prop- how do I assign the boundElementsByIndex setting to true? should this be passed in like a capability?

Ni, this is a setting: