How to handle redirects from one app to another

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.

  1. Press a button in App1 which will redirect the user to App2
  2. Validate fields in App2 and press a button that will return user to App1
  3. 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?

Thanks a lot!

we do not have problem with Android when we want send email from client using e.g. Gmail client. What is your scenario?

This is my current code:

//Click on the button that will redirect user to App #2

//User is now in App #2
//Make Asserts
Assert.assertEquals(driver.findElement(, “Test”);
//Click on the button that will return the user to App #1

//User in now back in App #1
//Make Asserts
Assert.assertEquals(driver.findElement(, “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?


make sure that you use FULL id with package name when you calling another app.

e.g. with Gmail client need to call like:

    @AndroidFindBy(id = "")
    private List<AndroidElement> gmail_SubjectInput;

Adding the package name to the id worked perfectly. Thanks so much!

Hi, do you have an idea on how to do the same in iOS? I already have the package name but the elements do not have an ID. I can only use the xpath.

package name in IOS? seriously?

I believe the Bundle ID in iOS is same as the Package name in Android.

Any idea how to refer to a UI element in another app for iOS? I tried using the same format as Android but it didn’t work. See format below: