How to enter device passcode in wireless test automation

-How to enter device passcode in wireless test automation


I am using XCTest to run a test with Xcode wireless debugging feature turned on. Setting up wireless debugging needs passcode enabled on iPhone

In the test, it will lock the screen in the middle of workflow. When unlocking the screen, it asks for a device passcode. But I could not find a way to enter device passcode. Since at this moment, XCUIApplication could not find any element on the passcode screen.


Can anyone know:

  1. What Bundle ID is the passcode screen? Or
  2. How to type or enter device passcode using automation?

Replies

I have just found the answer, you can use the springboard:

Code Block
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let passcodeInput = springboard.secureTextFields["Passcode field"]
passcodeInput.tap()
passcodeInput.typeText("abc\r")

  • This works with iOS 17.0.1 in the Simulator. However it doesn't work in iOS 17.4 anymore. Did the string "Passcode field" change in iOS 17.4 maybe?

Add a Comment

I have exactly the same problem. I tried your code but it stops at the first line until I manually tap the code otherwise the test fails after a timeout.