XCUIElement with zero frame but showing.

I have a bug I am writing a UI Test for and I am struggling to find a way to test the fixed UI vs the buggy UI. In the buggy version, the UI element is visible on the screen but has a 0,0 width and height. It's visible because it's not set to 'clip to bounds', so it's overlaying the rest of my UI.

The app sets the element to be hidden in certain situations and I wanted to make sure in my test, that it's not on the screen in that situation. The problem is that .exists returns true in both situations (.hidden == true, .hidden == false), and .isHittable always returns false because its either no on the screen at all or has a 0,0 width, height.

So I can't use .exists; I can't use .isHittable; and I can't use the .frame either. Is there simply a way to check if it's actually visible?

Visibility as defined by the hidden property on a UIView does not always correlate to the accessibility properties that are exposed to UI Testing. My recommendation would be to investigate ways of hiding this view from the accessibility hierarchy when you don't want it to be known by UI Testing.

There are some interesting strategies for this covered by this WWDC talk from last year: https://developer.apple.com/videos/play/wwdc2023/10035/?time=779

XCUIElement with zero frame but showing.
 
 
Q