How to work with an already installed application using appium?

Please browse to below url to see prerequisites for mobile test automation:

New android application run in appium:
Please visit below url to download apk file from Google play Store

The path to APK file:
Download desired android application file from Google Play Store and save the desired location on the computer. We create a file object which represents the actual apk file on the disk. I placed my apk file in the folder '/home/jannat/apk/'.

// Path of the android application file (apk)
File appDir = new File("/home/jannat/apk");
// path with android application name
File app = new File(appDir, "selendroid-test-app-0.17.0.apk");
// An absolute local path to the APK file
capabilities.setCapability(“app”, app.getAbsolutePath());

Example:

Handle already installed an android application using appium:
We need to provide android application package name and activity name which help to open already installed application.

Please browse to below url to find android application package name and activity name.

// Java package of the tested Android app
capabilities.setCapability("appPackage", "io.selendroid.testapp");
// An activity name for the Android activity you want to run from your package.
capabilities.setCapability("appActivity", "io.selendroid.testapp.HomeScreenActivity");

Demo java program for selendroid-test-app
 import io.appium.java_client.android.AndroidDriver;  
 import java.io.File;  
 import java.io.InterruptedIOException;  
 import java.net.MalformedURLException;  
 import java.net.URL;  
 import java.util.concurrent.TimeUnit;  
   
 import org.openqa.selenium.By;  
 import org.openqa.selenium.remote.CapabilityType;  
 import org.openqa.selenium.remote.DesiredCapabilities;  
   
public class SimpleAppiumProgram {  
   
  private static AndroidDriver driver;  
   
   public static void main(String []arg) throws MalformedURLException, InterruptedException{  
   
     // Created object of DesiredCapabilities class.  
     DesiredCapabilities capabilities=new DesiredCapabilities();  
   
     // Set android deviceName desired capability. Set genymotion emulator name.  
     capabilities.setCapability("deviceName", "192.168.56.101:5555");  
   
      // Set android platformName desired capability. It's Android in our case here.  
     capabilities.setCapability("platformName", "Android");  
   
     // Set android VERSION desired capability. Set genymotion emulator OS version.  
     capabilities.setCapability(CapabilityType.VERSION, "6.0.0");  
   
     // Set BROWSER_NAME desired capability. It's Android in our case here.  
     capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");  
   
      // Java package of the tested Android app
     capabilities.setCapability("appPackage", "io.selendroid.testapp");

      // An activity name for the Android activity you want to run from your package.
     capabilities.setCapability("appActivity", "io.selendroid.testapp.HomeScreenActivity");

     driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);  
   
     driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);  
     Thread.sleep(5000);  
   
   
     driver.findElement(By.id("io.selendroid.testapp:id/my_text_field")).sendKeys("Hiro Mia");  
   
     driver.findElement(By.id("io.selendroid.testapp:id/touchTest")).click();  
     driver.quit();  
   
   
   
   }  
 }  
   
   

10 comments:

  1. your blog is so useful for the those want to learn more and explore their knowledge keep on updating ..........

    Best Training Institute in chennai

    ReplyDelete
  2. Thanks a lot for sharing
    Having good health is what most people out there wants but can not achieve. some people takes buy ibogaine online AND buy weed online to get it.

    ReplyDelete
  3. magnificentincense.com
    24K Monkey Classic Incense 10g
    AK-47 – X10 / PREMIUM
    Bizarro Incense
    Buy Black Mamba Incense Online
    Buy WTF Herbal Incense
    Cloud9 Mad Hatter Incense
    Crazy Monkey Incense
    k2 spray on paper
    k2 paper sheets
    Klimax Potpourri 15xxx Coconut(10g)
    Crazy Monkey Incense
    Cloud9 Mad Hatter Incense
    Buy Purple Diesel Incense Online
    Buy Pure Fire Herbal Incense Online
    Buy Kisha Cole Incense (11g) online
    Buy KUSH HERBAL INCENSE online
    Buy Mind Trip Incense Online
    Buy Platinum XXX Herbal Incense online
    buy Orange Platinum Caution 10G
    Buy OMG HERBAL POTPOURRI 10G online

    ReplyDelete
  4. https://bestmjstrainsonline.com/

    Buy Liquid Incense Cheap
    Buy K2 E-Liquid online
    Cheap Herbal incense

    Buy K2 Infused paper spray online, order K2 Spray online +1 (925) 526-5453

    https://bestmjstrainsonline.com/product/5-co2-cannabis-oil-cartridges/



    ReplyDelete
  5. Dispensary care is what many people lack in the interior areas of the world. Weed, can help you recover shortly. marijuana. people face a lot of health issues everyday without solution. Weed However, crack cocaine has always been a perfect remedy for ill health. Nevertheless, cocaine may also help.

    ReplyDelete