Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Switch from one application to another application at runtime in Appium

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.59k
    Comment on it

    There are many times we have to switch from one application to another while in the middle of execution. In this case we have to switch to the second application and then perform some action and then again return back to the previous application.

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
    capabilities.setCapability("device", "Android");
    capabilities.setCapability("deviceName", "Galaxy Note3");
    capabilities.setCapability("platformVersion", "5.0");
    capabilities.setCapability("platformName","Android");
    
    capabilities.setCapability("appPackage","com.android.contacts");
    capabilities.setCapability("appActivity","com.android.contacts.activities.PeopleActivity");
    driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);
    
    //launch settings Application
    driver.startActivity(settingsAppPackageName, settingsAppActivityName);
    
    //Switch ON Bluetooth
    driver.findElement(By.id("Bluetooth_id")).click();
    
    //Re launch Caller Application
    driver.startActivity(callerAppPackageName, callerAppActivityName);
    

    Suppose we are on the mobile calling and we want to switch on Bluetooth then first the caller screen will be launched, then we will launch the settings screen and switch on the Bluetooth. Now again move back to the previous activity.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: