testmanagerd constantly requests password to enable UI Automation on macOS Monterey

We updated our CI machine to:

  • macOS Monterey Version 12.0.1
  • Xcode Version 13.1 (13A1030d)

We started to receive UITest failures with following error:

Testing failed:
	MemoryLeaksUITests:
		MemoryLeaksUITests-Runner (3507) encountered an error (The test runner failed to initialize for UI testing. If you believe this error represents a bug, please attach the result bundle at /Users/dev/Library/Developer/Xcode/DerivedData/MemoryLeaks-dduvihbyiuzwdnawggthtfwdgwks/Logs/Test/Test-MemoryLeaks-2021.11.05_13-43-58-+0300.xcresult. (Underlying Error: Timed out while enabling automation mode.))

The failure disappears if we enable UIAutomation for testmanagerd by providing password

However it's not one time action. This permission dialog still appears after some time during a day. We noticed it constantly appears after machine reboot.

Unfortunately it blocks us from using our CI machine as test runner.

There is no option(checkbox) to permanently enable(provide password) automation in this dialog. Also it's not possible to add it in Settings -> Security & Privacy -> Privacy - Automation.

Here is a sample project on GitHub to reproduce the issue.

Steps:

  1. Reboot machine
  2. Run in terminal

xcodebuild -target MemoryLeaksUITests -scheme MemoryLeaks test

Answered by myurik2 in 694516022

I opened TSI for the issue and got reply from Apple DTS Engineer that resolves my issue:

The automationmodetool command line tool allows you to manage UI automation security preferences, see its man page for details. To resolve your issue, run the following command as a administrator on your machine: 
       automationmodetool enable-automationmode-without-authentication

To disable this mode, run the following command as a administrator on your machine: 
     automationmodetool disable-automationmode-without-authentication

Note that the man page shows leading dash in front of each of the above two commands, it is a bug. Please disregard it and use the commands as described above. 
Accepted Answer

I opened TSI for the issue and got reply from Apple DTS Engineer that resolves my issue:

The automationmodetool command line tool allows you to manage UI automation security preferences, see its man page for details. To resolve your issue, run the following command as a administrator on your machine: 
       automationmodetool enable-automationmode-without-authentication

To disable this mode, run the following command as a administrator on your machine: 
     automationmodetool disable-automationmode-without-authentication

Note that the man page shows leading dash in front of each of the above two commands, it is a bug. Please disregard it and use the commands as described above. 

@prakhg It's actual for macOS Monterey only. For Big Sur this issue is not exists.

I execute this command on host machine which is wirelessly connected to X code. automationmodetool enable-automationmode-without-authentication but I still get this exception Underlying Error: Timed out while enabling automation mode. Am I doing something wrong?

When I execute automationmodetool to get the status

ip-172-30-20-122:~ root# automationmodetool
Automation Mode is disabled.
This device DOES NOT REQUIRE user authentication to enable Automation Mode.

I am on X code version 13.2 and Monterey 12.2. iPad is iOS 15.3.1 (19D52)

Please advise.

testmanagerd constantly requests password to enable UI Automation on macOS Monterey
 
 
Q