I am trying to remove an app from the app switcher using xcuitest (basically kill the app). The issue is app.terminate() just terminates it and puts it on background mode. Since there is no press on home action on new iPhones, there is a way to swipe up from the bottom of the screen ?
CodePudding user response:
app.terminate()
does actually kill the app, it does not put it in background mode. What you see in the app switcher is a leftover snapshot
of the running app but it is not actually running. If you tap on it, then the app is relaunched which might make you think that it was on background mode. A possible example to open the Dock:
extension XCUIApplication {
func openDock() {
let swipeStart = coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.999))
let swipeEnd = coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.001))
swipeStart.press(forDuration: 0.1, thenDragTo: swipeEnd)
}
}
I would advise you use app.terminate()
, then create a new XCUIApplication instance for springboard with let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
. You can then call this function like this springboard.openDock()
to open the Dock/App switcher (I am assuming). If it works then after you open it you can experiment with springboard.swipeUp()
to close all available apps.