Programmatically sending an app to background

前端 未结 4 1791

Is there a way to send the application to background? Similarly to how you can call XCUIApplication.terminate(), I have some UI Elements to test on applic

4条回答
  •  粉色の甜心
    2020-12-10 04:45

    In my case I wanted to background the app and open it where I previously left it. To background the app:

    XCUIDevice.shared.press(.home)
    

    To re-open the app where I left it:

    XCUIApplication().activate()
    

    Re-launching the app using XCUIApplication().launch() would launch the app from new.

    I am using Swift 4.2

提交回复
热议问题