Post

Replies

Boosts

Views

Activity

Unable to paste a string from XCTestCase
I am trying to put a string from my XCTestCase for my app under test to paste in. I am using the following code: override func setUp() { super.setUp() self.continueAfterFailure = false UIPasteboard.general.strings = [] self.app = XCUIApplication() self.app.launchArguments.append("UITests") let contrivedString:String = "String to test" UIPasteboard.general.string = contrivedString self.app.launch() } When I run this code, I am seeing this error when I try to set the values into the pasteboard: 2021-07-08 14:00:53.925277-0400 SampleUITests-Runner[59653:7119382] Could not save pasteboard named com.apple.UIKit.pboard.general. Error: Error Domain=PBErrorDomain Code=11 "The pasteboard name com.apple.UIKit.pboard.general is not valid." UserInfo={NSLocalizedDescription=The pasteboard name com.apple.UIKit.pboard.general is not valid.} Because the contrivedString's value isn't in the pasteboard, the app under test can't paste it in resulting in a failure. This code works on iOS 13.7, iOS 14.4.1, but if I try this on iOS 14.5.1 and above I get the error I mentioned above. Is there another way I am supposed to access the general pasteboard in the test runner on iOS 14.5.1 and above?
1
0
1.8k
Jul ’21