How to find Siri response window by bundle id

Hi, experts,

I want to find Siri response window by bundle id and use it for checking or printing, here is my example code:

XCUIDevice.shared.siriService.activate(voiceRecognitionText: "call mom")
let siriApp = XCUIApplication(bundleIdentifier: "***")
// Print out text from siriApp, 
// expecte print: "Sorry, I can't make a phone call with your iphone."

Where should I put into ***? I tried "com.apple.SiriViewService", "com.apple.siri.velocity", "com.apple.springboard' but nothing work

Any suggestion appreciated, thanks!

Answered by DTS Engineer in 853193022

The design of the Siri activation XCTest API here is so that you test the UI elements in your app that would update in response to a Siri activation that launches your app to the foreground and performs a specific action. In other words, you want to test your app's code directly, you aren't testing anything outside of your app's UI process that the system is displaying on behalf of your app. As an example, that would look like this for testing the value of a label inside your app that changes after handling an intent:

XCUIDevice.shared.siriService.activate(voiceRecognitionText: "Call mom using MyApp")

let statusLabelUpdated = NSPredicate(format: "self.label != \"Some Label Value\"")
let queryDescription = XCUIApplication().collectionViews.staticTexts["statusLabel"]
let siriQueryFullfillmentExpectation = expectation(for: statusLabelUpdated, evaluatedWith: queryDescription, handler: nil)
wait(for: [siriQueryFullfillmentExpectation], timeout: 60)

// Verify the label has the value expected
XCTAssert(queryDescription.label.contains("Some Label Value Past"))

— Ed Ford,  DTS Engineer

The design of the Siri activation XCTest API here is so that you test the UI elements in your app that would update in response to a Siri activation that launches your app to the foreground and performs a specific action. In other words, you want to test your app's code directly, you aren't testing anything outside of your app's UI process that the system is displaying on behalf of your app. As an example, that would look like this for testing the value of a label inside your app that changes after handling an intent:

XCUIDevice.shared.siriService.activate(voiceRecognitionText: "Call mom using MyApp")

let statusLabelUpdated = NSPredicate(format: "self.label != \"Some Label Value\"")
let queryDescription = XCUIApplication().collectionViews.staticTexts["statusLabel"]
let siriQueryFullfillmentExpectation = expectation(for: statusLabelUpdated, evaluatedWith: queryDescription, handler: nil)
wait(for: [siriQueryFullfillmentExpectation], timeout: 60)

// Verify the label has the value expected
XCTAssert(queryDescription.label.contains("Some Label Value Past"))

— Ed Ford,  DTS Engineer

How to find Siri response window by bundle id
 
 
Q