How to close and open app in saucelabs appium after each scenario cucumber?

Hi all,

I am trying to close the application and open it again using appium.

The application is closing but not open from where it is closed in saucelabs.

I am using Java, Cucumber, JUnit, Saucelabs.

I am using below code. It is working fine in real android, iOS device. But not working while executing in saucelabs iOS device.

driver.terminateApp(“package.name.test”);
driver.activateApp(“package.name.test”);

That doesn’t even work if you do it manually. Maybe you are looking to background the app instead so it retains state?

https://appium.io/docs/en/commands/device/app/background-app/