Hi @jonahss, Thanks for the reply.
I am using Android 5.1.1 at device side and Android 4.4(API Level-19) at appium side(as Capability).
For the first time, App-1 starts completely New, but for the second time(App1->App2->App1), App-1 is starting where I left it which I actually want.
Please check the Code Below:
App-1:
@BeforeClass
public void setup() throws MalformedURLException {
capabilities
.setCapability(
"app",
"C:\\Users\\dhiraj01\\Downloads\\smartdriver-android-1.6-SNAPSHOT[staging644].apk");
capabilities.setCapability("appPackage", "com.tower.smartdriver");
capabilities.setCapability("appActivity", ".activity.WelcomeActivity");
capabilities.setCapability("deviceName", "0cbbdc0a032f9efa");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appWaitActivity",
".activity.WelcomeActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities);// new RemoteWebDriver is Selenium Specific Class.
}
@Test
Test_code{
--------
--------
--------
driver.quit();
Lockito start_Lockito = new Lockito(); //Switching to App-2
start_Lockito.setup();
//Come Back to App-1
DesiredCapabilities capabilities_control = new DesiredCapabilities();
capabilities_control.setCapability(MobileCapabilityType.APP_PACKAGE,
"com.tower.smartdriver");
capabilities_control.setCapability(MobileCapabilityType.APP_ACTIVITY,
".activity.WelcomeActivity");
capabilities_control.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities_control.setCapability(MobileCapabilityType.DEVICE_NAME, "0cbbdc0a032f9efa");
capabilities_control.setCapability(MobileCapabilityType.APP_WAIT_ACTIVITY,
".activity.MainActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities_control);
wait.until(ExpectedConditions.elementToBeClickable(By
.id("com.tower.smartdriver:id/start_trip_btn")));// Appium showing Success for this.
driver1.findElement(By.id("com.tower.smartdriver:id/start_trip_btn")).click(); //Appium is
//showing success for it.
wait2.until(ExpectedConditions.textToBePresentInElement(
driver.findElement(By.id("com.tower.smartdriver:id/log_trip_distance_display")), "2.2"));
------------
------------
------------
}
App-2:
@BeforeClass
public void setup() throws MalformedURLException {
DesiredCapabilities capabilities1 = new DesiredCapabilities();
capabilities1.setCapability("appPackage", "fr.dvilleneuve.lockito");
capabilities1.setCapability("appActivity", ".ui.SplashscreenActivity_");
capabilities1.setCapability("deviceName", "0cbbdc0a032f9efa");
capabilities1.setCapability("platformName", "Android");
capabilities1.setCapability("appWaitActivity",
".ui.ItinerariesActivity_");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities1);
List<WebElement> Trip_Selection = driver.findElements(By
.className("android.widget.RelativeLayout"));
Trip_Selection.get(2).click();
WebElement Play_Trip = driver.findElement(By
.id("fr.dvilleneuve.lockito:id/menuPlay"));
Play_Trip.click();
driver.quit();// going to App-1
}
Hope this code help you figuring out the error.