When UI testing in Xcode(7.2 and 7.3), my tests sometimes fail with a rather generic error:
Assertion Failure: UI Testing Failure - Failure fetching attributes for element
I tend to get this error when calling .hittable
or .tap()
on an element but I cannot tell why. I've checked that the elements I'm dealing with all have their accessibility settings correctly setup and that any container views that they are in don't have accessibilty enabled. Alas, this doesn't seem to resolve the problem.
The console log reveals:
UI Testing Failure - Failure fetching attributes for element <XCAccessibilityElement: 0x7e68ae50> pid: 89032, context: 4D9272C7-3024-4062-B0FA-E16EF426F17A, payload: { pid = 89032; "uid.elementID" = 1432; "uid.elementOrHash" = 2125772976; }: Error Domain=XCTestManagerErrorDomain Code=13 "Error copying attributes -25202" UserInfo={NSLocalizedDescription=Error copying attributes -25202}
I've tried searching around and managed to find it's already been logged but there appears to be no current solution (radar link) even for Xcode 7.3.
It seems that sometimes if I restart the simulator/device this error doesn't happen but this isn't a nice solution.
You can temporarily use XCUICoordinate.tap()
as an alternative. For example, replace button.tap()
with button.coordinateWithNormalizedOffset(CGVector(dx: 0.5, dy: 0.5)).tap()
.
I ran into the same issue, and the workaround works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With