XCUIApplication sees no elements

I'm trying to add UI tests to my MacOS application. But XCUIApplication doesn't see any elements. If I start UI test, pause it with a breakpoint and run `po XCUIApplication().windows.count` or `XCUIApplication().buttons.count` it always returns 0. When running recording, it generates code where it just click on a window, which is mysteriously found by the name, while if I run the same command with `po` it shows me nothing.


I've tried creating empty mac app and added a few buttons there - it works ok an sees all the elements perfectly.


What may be wrong? Is there anything that I'm missing?

Replies

If you run Accessibility Inspector against your app, does it see the UI hierarchy?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"