This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

Hi,
I am trying to use Appium and need to open Chrome and a Native app on Android. I would like to do so using 1 driver instance.
Scenario:

  1. Start the chrome activity, go on a particular website, retrieve a token
  2. Start the activity by passing the token retrieved in 1)

Here is a sample of my code

    DesiredCapabilities clientCapabilities = new DesiredCapabilities();
    clientCapabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, appPackage);
    clientCapabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, activity);
    clientCapabilities.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, true);
    clientCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, deviceConfiguration.getDeviceName());
    clientCapabilities.setCapability(MobileCapabilityType.UDID, deviceConfiguration.getUDID());
    clientCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, deviceConfiguration.getPlatformVersion());
    clientCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
    clientCapabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 10000);

    Activity activity = new Activity("com.android.chrome","com.google.android.apps.chrome.Main");
    driver.startActivity(activity);
    driver.get("https://mywebsite.com"); <-------- it doesn't work, I am not redirected to that website !

I have also tried to add clientCapabilities.setCapability(MobileCapabilityType.BROWSER_NAME, “Chrome”) when setting up the capabilities, however if I do that the driver is not able to find any element in the native app when I start the activity for the native app.

What am I missing?

  • created

    Dec '17
  • last reply

    Dec '17
  • 1

    reply

  • 434

    views

  • 1

    user

I have tried using
activity = new Activity(“com.android.chrome”,“com.google.android.apps.chrome.Main”);
driver.startActivity(activity);

    ((AndroidElement) driver.findElement(MobileBy.id("com.android.chrome:id/url_bar"))).setValue("https://website");
    ((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.ENTER);

I get access to the website but it appears that I cannot locate any element using xpath…
Any suggestion?