0

I have a native mobile App and automated by using a Appium Driver (AppiumDriver driver) which is working OK and by one Feature of App e.g. unlock Account send an Email to user which need to be confirmed by User.

So I have find out how to get the link in Email and how to get the URL from send Email.(saved in a String var e.g. "href")

So when the automation run I am in Mobile App in window "INFORMATION" which inform user we have send an Email to confirm. Now my question is

  1. How can I switch from native mobile App (screen INFORMATION)and Put the URL in Browser and after that should open in Browser a Window which ask user enter new password and repeat it and then press OK ? After that I should again back to the Mobile App.

  2. Do I need another driver like a Web Driver (additional to appium Driver mentioned above) to handle the Actions in Browser after switch?

Thanks for any Support

This my Capability:

public AppiumDriver<MobileElement> driver;

.....

public DesiredCapabilities cap = new DesiredCapabilities();

.....

            cap.setCapability("deviceName", helper.getConfiguration(configFileName, "androidDeviceName"));
            cap.setCapability("platformName", helper.getConfiguration(configFileName, "androidPlatformName"));
            cap.setCapability("PlatformVersion", helper.getConfiguration(configFileName, "androidPlatformVersion"));
            cap.setCapability("automationName", "uiautomator2");

            cap.setCapability("MobileCapabilityType.FULL_RESET", android_mct_fullReset);
            cap.setCapability("MobileCapabilityType.NO_RESET", android_mct_noReset);
            cap.setCapability("appium-version", helper.getConfiguration(configFileName, "appiumVersion"));
            cap.setCapability("language", helper.deviceLanguage);
            cap.setCapability("locale", helper.deviceLocale);
            cap.setCapability(AndroidMobileCapabilityType.UNICODE_KEYBOARD, "true");
            cap.setCapability("app", app.getAbsolutePath());

....

        driver = new AppiumDriver<MobileElement>(new URL("http://localhost:4723/wd/hub"), cap);
AKADO
  • 481
  • 1
  • 11
  • 19

2 Answers2

2

I think this will be achieved with :

driver.startActivity(new Activity("com.example", "ActivityName"));

Import by :

import io.appium.java_client.android.Activity;

With this method you can switch application, you must know the APP_PACKAGE and APP_ACTIVITY that you have, try this link or this link to learn this.

This is example the APP_PACKAGE and APP_ACTIVITY google chrome browser from play store :

driver.startActivity(new Activity("com.android.chrome", "com.google.android.apps.chrome.Main"));

You don't need to make a new initialize driver for the browser, just do it.

Your native apps start here
...

Switch to browser

//example chrome
driver.startActivity(new Activity("com.android.chrome", "com.google.android.apps.chrome.Main"));
....

//back to last activity your native app
driver.startActivity(new Activity("yourAPP_PACKAGE", "yourAPP_ACTIVITY"));
frianH
  • 7,295
  • 6
  • 20
  • 45
0
  1. You can use Activity class to launch another application using AndroidDriver.startActivity() function like:

    Activity activity = new Activity("activity.package", "activity.name");
    activity.setStopApp(false);
    ((AndroidDriver<MobileElement>) driver).startActivity(activity);    
    
  2. An easier way would be just going for Launch command available via SeeTest Appium Extension like:

    seetest.launch("activity.name", false, false);  
    
Dmitri T
  • 159,985
  • 5
  • 83
  • 133