XCUITest: accessibilityIdentifier is not being detected when recording on certain devices

accessibilityIdentifier is not being detected when recording on certain devices.


Here are the recording results when used on certain devices.

Note that all of these refers to the same element.


The accessibilityIdentifier appeared on iPhone 5s but not on other devices.


iPhone 8

app.children(matching: .window).element(boundBy: 0).children(matching: .other).element(boundBy: 1)
.scrollViews.children(matching: .other).element.children(matching: .collectionView).element.children(matching: .cell).
element(boundBy: 0).children(matching: .other).element(boundBy: 0).tap()


iPhone 7

app.children(matching: .window).element(boundBy: 0).children(matching: .other).element(boundBy: 1)
.scrollViews.children(matching: .other).element.children(matching: .collectionView).element.children(matching: .cell).
element(boundBy: 0).children(matching: .other).element(boundBy: 0).tap()

iPhone 6s

app.children(matching: .window).element(boundBy: 0).children(matching: .other).element(boundBy: 1)
.scrollViews.children(matching: .other).element.children(matching: .collectionView).element.children(matching: .cell).
element(boundBy: 0).children(matching: .other).element(boundBy: 0).tap()


iPhone 5s

app.scrollViews.otherElements.collectionViews.staticText["SAMPLE TEXT"].tap()



Preferably, It should be the same as iPhone 5s. Since that will allow the tests to be more dynamic based on the actual text instead of relying on indexes.


Another thing to note is that the accessibilityIdentifier appears as value when using accessibilityInspector.