I’m creating a test script for an Android app using Java and I am stuck in automating the scenario below which involves redirection from 1 app to another.
Press a button in App1 which will redirect the user to App2
Validate fields in App2 and press a button that will return user to App1
Perform some more tests in App1
My script is failing in Step 2 since the android driver does not recognize the UI elements in App2. Can someone help me in how to handle this?
//Click on the button that will redirect user to App #2
driver.findElement(By.id(appButton1)).click();
//User is now in App #2
//Make Asserts
Assert.assertEquals(driver.findElement(By.id(sometext)).getText(), “Test”);
//Click on the button that will return the user to App #1
driver.findElement(By.id(appButton2)).click();
//User in now back in App #1
//Make Asserts
Assert.assertEquals(driver.findElement(By.id(Parameters.SCC_LINE2)).getText(), “Test”);
The problem is that the script does not recognize the UI elements in App #2. Should I have in my code a line that will switch to the other app?