I want to make my app to go to background, and then comeback to the foreground.
To make an app to go background: XCUIDevice.shared().press(XCUIDeviceButton.home)
To terminate an app(force tap): XCUIApplication().terminate()
To launch the app: XCUIApplication().launch()
Problem: when I try to close and open the app, the launch() method clears the app from background and it opens the app freshly.
I saw this comment regarding this. But cant able to figure out it in UI test. I'm using Swift. Help needed!!