Programmatically sending an app to background

前端 未结 4 1789

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 05:00

    In Xcode 9.0, Apple introduced XCUIApplication.activate(). activate() will launch the application if necessary, but will not terminate it if it is already running. Thus:

    func testExample() {
        // Background the app
        XCUIDevice().press(.home)
        // Reactivate the app
        XCUIApplication().launch()
    }
    

提交回复
热议问题