Switching between iOS native app and safari and start the app exactly from same page where I leave it and went to safari

Scenario 1:
In my ios, the 1st stage is signup which is a bit lengthy. I need to fill up 15 pages to complete the signup process. In 5th page is for a verification code, the code is already sent to the email id. so from this verification code page what I want to do is —>

  1. Switch to safari
  2. do the task in safari
  3. Want to come back the app in the verification code page.

I can do successfully step 1 & 2 . The problem is in step 3 when I have opened my app with driver.launchApp() command, the app starts from the beginning but I want to start it from the ‘verification code’ page.
Because if a start it from the first page then another code will be generated.

Scenario 2:
Suppose during run the script I got an error in the 4th page of my signup process. After fixing the problem I want to run it from the 4th page. What I mean is I want to start it exactly from the same place where I leave it last time. How can I do this in appium ???

Appium Desktop Version: 1.10.0
Xcode version : 10.1
Simulator: iphone- 6s (12.1)

Below I have attached my code, please have a look ,

public class Base {
private String reportDirectory = “reports”;
private String reportFormat = “xml”;
private String testName = “TestIOS”;
public static int counter= 0;
public AppiumDriver driver;
public static SeeTestClient client;

public DesiredCapabilities dc = new DesiredCapabilities();

static UUID uuid = UUID.randomUUID();
static long l = ByteBuffer.wrap(uuid.toString().getBytes()).getLong();
static String id = Long.toString(l, Character.MAX_RADIX);
static String storedId= id;


@BeforeTest
    public void setUp() throws MalformedURLException {
    dc.setCapability("reportDirectory", reportDirectory);
    dc.setCapability("reportFormat", reportFormat);
    dc.setCapability("testName", testName);

    dc.setCapability("automationName", "XCUITest");
    dc.setCapability("platformName", "iOS");
    dc.setCapability("deviceName", "iPhone 6s");
    dc.setCapability("platformVersion", "12.1");
    dc.setCapability("app", "/Users/bs215/IdeaProjects/meedapptest/Apps/MEED/meed.app");
    dc.setCapability(IOSMobileCapabilityType.BUNDLE_ID, "net.....");

    dc.setCapability("autoAcceptAlerts", true);
    dc.setCapability("fullReset", false);
    dc.setCapability("noReset", true);
    dc.setCapability("clearSystemFiles", true);
    dc.setCapability("autoWebview", true);
    driver = new IOSDriver<>(new URL("http://localhost:4723/wd/hub"), dc);
    client = new SeeTestClient(driver);
    driver.setLogLevel(Level.INFO);

}

@Test(priority = 11)
public void GMA_TC_10_verifyEmailVerificationCode () throws Exception{

    signupPage signUp= new signupPage();
   String code= other.varificationCode.emailid(driver);
   driver.launchApp();

}

package other;
public class varificationCode extends Base {

public static String emailId(AppiumDriver driver) throws Exception {

dc.setCapability(MobileCapabilityType.BROWSER_NAME, “Safari”);
dc.setCapability(“autoWebview”, true);

driver.get(“http://www.yopmail.com”);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
String requiredcode;

=======doing the task and get the code from mail========

return requiredcode;
}
}


can you please go through with above given example and check whether they are working or not.

Thnaks @auto_mate for your response. Yes , I have already took help from that example but can’t solve 3rd point of scenario1 and also not scenario 2 :frowning:

in your case when you switch to safari after getting verication code just try to close safari by clicking on menu option exit if present that will done your case
Otherwise just check whether naviagte().back() is available for ios in latest appium java client jar and if it works then it will done your case.

Resolved my problem by using back to app. so my scenario 1 has been completely solved now. Trying to solve scenario 2.

navigate().back() worked ?

I am able to launch safari using jSExecutor on the real device. I am unable to navigate to the url i want to go to. I have to keep switching between native app and safari for one of my test.