Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode UI Testing Failure - Computed invalid hit point

My Xcode UI testcode is failing with this error, when the test runs on iPad Pro 12.9 inch. For all iPhone model and for iPad Retina, there is no error seen.

Assertion Failure: EasyTVUITests.m:81: UI Testing Failure - Computed invalid hit point (-1.0, -1.3) for Cell 0x600000377dc0: traits: 8589934592, {{411.0, -1373.0}, {813.3, 106.3}}

The failing test code line is this one:

[[app.tables[@"programs"].cells elementBoundByIndex:17] tap];

What does the error actually mean, and how do I debug it?

Here is the full run up to the error:

Tap Cell

Wait for app to idle

Find the Cell

   Snapshot accessibility hierarchy for com.[hidden]

   Find: Descendants matching type Table

   Find: Elements matching predicate '"programs" IN identifiers'

   Find: Descendants matching type Cell

   Find: Element at index 17

   Wait for app to idle

Synthesise event

   Assertion Failure: EasyTVUITests.m:81: UI Testing Failure - Computed invalid hit point (-1.0, -1.3) for Cell 0x600000377dc0: traits: 8589934592, {{411.0, -1373.0}, {813.3, 106.3}}

That the index is 17 is not important - I am just trying to pick a random cell. I tried another index, but it did not make any difference.

Visually the iPad Pro version does not look "wrong" or different from the iPad retina version.

This is Xcode 8.1 and the iPad simulator runs iOS 10.1.

like image 265
Kobski Avatar asked Mar 11 '23 16:03

Kobski


2 Answers

I had the exact same issue on iPad Pro (12.9 inch), while my code was running smoothly on iPad Retina.

Do you use the XCUIElement's isHittable test somewhere before the failing line? Because for some reason, in my code, running this test on the iPad Pro (12.9 inch) returns YES while on all other simulators it returns NO.

I found it comparing the console outputs of runs on different simulators. Hope it helps.

like image 131
Johann Avatar answered Mar 26 '23 22:03

Johann


I also have had this kind of issue, an invalid hit point, but for an element which was displayed on screen, so not a scroll issue.

I managed to fix it for iPad Retina and iPad Pro 9.7 inch using the force tap method described on this page http://samwize.com/2016/02/28/everything-about-xcode-ui-testing-snapshot/

But it wasn't working on iPad Pro 12.9inch because the isHittable property was true on it.

In the end the problem was I was trying to tap an element on the main view while a popover was displayed, so while it was in reality hittable, xcuitests assumed it wasn't. I now perform a dummy forceTap actions to force dismiss the popover before performing the tap action that used to be failing. Works well on all three kind of iPads.

like image 32
Jerome Diaz Avatar answered Mar 26 '23 22:03

Jerome Diaz