How to retain AppiumDriver instance?

Hi,

This is what I do.

  1. Launch App (iOS).
  2. Sign in to App.
  3. Home page is displayed after successful sign in.

AppiumDriver appiumDriver = new iOSDriver<>(new URL(“http://myurl.com”), getDesiredCapabilities());

I have a couple of test cases in the Home page. If any of my test cases in Step#3 (Home page) fails, the test suite execution comes to an end and appiumDriver instance becomes null. When I want to re-run my tests, I would like to continue from the Home page itself instead of starting from the beginning from Login page.

While it is possible to push the app to the background and then bring to foreground, the appiumDriver instance however becomes null after the test suite execution due to which I am forced to create a new instance of appiumDriver but that would mean doing it again from app launch and not from the home page directly.

Can someone please suggest on how can this be resolved? Is there a way to get the old appiumDriver instance instead of creating a new one?

Thanks,
GD

First of all once the driver is intialised and the session is created for teh appium instance ,then it cannot be revoked or retained when its closed. Better start the execution and dont stop the server… keep it running…

1 Like

Thank you for your response.

I am not stopping the server nor am I explicitly closing the session. Am using TestNG to run my automation suite.
Once the suite execution finishes, the created appiumDriver instance and appiumDriver.getSessionid() become null while the server continues running.

Try passing “newCommandTimeout” in capabilities with desired wait time.

Hopefully this will resolve your issue.