Running Mac App UI Tests fails on a CI runner with locked screen

Hi everyone,

I'm trying to run a Mac app UI tests on our CI servers (Mac minis). The servers are logged in, but the lock screen is active (aka, the active process is the com.apple.loginwindow). UI tests end up failing with:

Failed to activate application <bundle at path> (current state: Running Background)

Is there any way to run Mac UI tests on a server like this without having to disable the lock screen? Our admins will likely not accept that solution, and I agree with them. Aside from running a full VM just for the UI tests, I can't find any solution.

Thank you,

Miguel Arroz

Answered by DTS Engineer in 900533022

@arroz Thanks for the post. There is no native way to run macOS XCUITest UI tests on a locked session. macOS security architecture strictly prevents it.

XCUITest relies on the macOS Accessibility API to inspect the view hierarchy and user events. It also requires the target application to be activated and brought to the foreground.

Hope this helps

Albert  WWDR

Accepted Answer

@arroz Thanks for the post. There is no native way to run macOS XCUITest UI tests on a locked session. macOS security architecture strictly prevents it.

XCUITest relies on the macOS Accessibility API to inspect the view hierarchy and user events. It also requires the target application to be activated and brought to the foreground.

Hope this helps

Albert  WWDR

Running Mac App UI Tests fails on a CI runner with locked screen
 
 
Q