Xcode 9.2, Simulator 8 plus 11.2(tried with all the simulators):
I am querying for an element on the screen, I can see it is visible and my debug log also says the element exists on the screen but, the UITestFramework is unable to find an element and sends an Assertion failure error.
I have tried adding a sleep of 1 sec, it sometimes works but not everytime.
Screen hierarchy printed in the logs:
↪︎Find: Descendants matching type Button
Output: {
Button, 0x600000187840, traits: 8589934849, {{352.5, 72.0}, {6.5, 20.0}}, identifier: 'System:fwd_arr', label: 'arrow right'
Button, 0x60000019d8e0, traits: 8589934849, {{352.5, 116.0}, {6.5, 20.0}}, identifier: 'Awake:fwd_arr', label: 'arrow right'
Button, 0x6000001883a0, traits: 8589934849, {{352.5, 160.0}, {6.5, 20.0}}, identifier: 'Sensor:fwd_arr', label: 'arrow right'
Button, 0x600000193db0, traits: 8589934849, {{352.5, 204.0}, {6.5, 20.0}}, identifier: 'Priority:fwd_arr', label: 'arrow right'
Button, 0x60000019d190, traits: 8589934849, {{352.5, 248.0}, {6.5, 20.0}}, identifier: 'Random:fwd_arr', label: 'arrow right'
Button, 0x60000019ff10, traits: 8589934849, {{352.5, 292.0}, {6.5, 20.0}}, identifier: 'Wifi:fwd_arr', label: 'arrow right'
Query:
t = 17555.64s Find: Elements matching predicate 'elementType == Button AND "Priority:fwd_arr" IN identifiers'
t = 17555.65s Snapshot accessibility hierarchy for app with pid 38889
t = 17555.65s Find: Descendants matching type Button
t = 17555.65s Find: Elements matching predicate 'elementType == Button AND "Priority:fwd_arr" IN identifiers'
t = 17555.65s Snapshot accessibility hierarchy for app with pid 38889
t = 17555.65s Find: Descendants matching type Button
t = 17555.65s Snapshot accessibility hierarchy for app with pid 38889
t = 17557.98s Find the "Priority:fwd_arr" Button
t = 17558.06s Find the "Priority:fwd_arr" Button
t = 17561.14s Tap "Priority:fwd_arr" Button[0.10, 0.10]
t = 17561.14s
Wait for TestingApp to idle
t = 17561.22s Find the "Priority:fwd_arr" Button
t = 17561.40s Wait for TestingApp to idle
t = 17563.77s Assertion Failure: UITests.m:1752: Failure fetching attributes for element <XCAccessibilityElement: 0x608000462280> pid: 38889, elementOrHash.elementID: 105553219486848.179888: Error Domain=XCTDaemonErrorDomain Code=13 "Error copying attributes -25202" UserInfo={NSLocalizedDescription=Error copying attributes -25202}
Thanks for your help in advance.