user1244546
user1244546

Reputation: 79

iOS XCTestCase to launch, perform some actions, kill the app and re-launch app

I have to automate following scenario using swift and XCTestCase on iOS simulator.

I found in one of our questions to use the below snippet.

    XCUIDevice.shared().press(XCUIDeviceButton.home)
    sleep(60)
    XCUIDevice.shared().siriService.activate(voiceRecognitionText: "Open {appName}")

It did not work for me, can some one please suggest any different approach.

thanks,

Upvotes: 0

Views: 2463

Answers (1)

Bartosz Janda
Bartosz Janda

Reputation: 1661

To launch or re-launch use launch:

XCUIApplication().launch()

To terminate application use terminate(). But according to the documentation:

If the application is already running, this call will terminate the existing instance, to ensure a clean launch state for the newly launched instance.

Shortly. Your test could look like:

XCUIApplication().launch()
// some actions
XCUIApplication().launch()
// some action

Upvotes: 3

Related Questions