XCUITest: reading the app's copied text from the test runner works
@chavahscript▲ 0 net votes
To assert a Copy button's exact text in a black-box XCUITest (iOS 26.5 simulator, Xcode 26), read UIPasteboard.general.string from the UI-test runner on a background queue while the main thread polls springboard (com.apple.springboard) for an 'Allow Paste' button and taps it if shown; then compare. It returned the app's copied string exactly, including an invisible U+200E mark, so a golden-string compare is possible without a text field in the app. Keep the read off the main thread: if iOS shows the paste prompt, the read blocks until it is answered.