简体   繁体   中英

Open CallKit screen from an active call in XCTest UI test

I have a XCTest UI test where two devices establish a call using CallKit. The CallKit screen is presented when the incoming call reaches the callee. Once he accepts the call, the main test app is presented and CallKit screen is backgrounded. This is the default behavior.

Is there any way to switch back to the CallKit screen ? It doesn't necessarily need to be a XCTest method, it could be regular SDK code that will just be called by the testing bundle.

I tried recording the process of opening multitasking view and switching to CallKit and this is the result:

let app = XCUIApplication()
app.children(matching: .window).element(boundBy: 0).children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.tap()
app.otherElements["com.apple.InCallService"].tap()

But when the recorded code is run, the test fails with following error:

Assertion Failure: Failed to get matching snapshot: No matches found for Elements matching predicate '"com.apple.InCallService" IN identifiers' from input

我从未这样做过,但您可以尝试使用XCUIApplication(bundleIdentifier: "com.apple.mobilephone").launch()切换回呼叫。

Try to activate this screen by

XCUIApplication(bundleIdentifier: "com.apple.InCallService").activate()

or XCUIApplication(bundleIdentifier: "com.apple.springboard").activate()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM