• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Programming Languages
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
  • Automation Tools and Different Tools
    • Web Automation
      • Selenium with Java
        • Selenium Basic
        • Selenium Advance
        • Selenium Realtime
        • Framework
        • Selenium Interview
        • Selenium Videos
        • Selenium with Docker
      • Selenium with Python
      • WebdriverIO
        • Selenium Webdriver C# Tutorial
      • Cypress
      • Playwright
    • TestNG
    • Cucumber
    • Mobile Automation
      • Appium
    • API Testing
      • Postman
      • Rest Assured
      • SOAPUI
    • testRigor
    • Katalon
    • TestProject
    • Serenity BDD
    • Gradle- Build Tool
    • RPA-UiPath
    • Protractor
    • Windows Automation
  • Automation For Manual Testers
  • Services
  • Online Training
  • Contact us
  • About me
  • Follow us
    • Linkedin
    • Facebook Group
    • Facebook Page
    • Instagram

Automation

Selenium WebDriver tutorial Step by Step

You are here: Home / Appium Tutorials / Automate Mobile native applications using Appium/Selenium

Automate Mobile native applications using Appium/Selenium

December 15, 2015 by Mukesh Otwani 29 Comments

Appium

Today in this post you will get the complete information about how you can automate native application using Appium

 

In previous, article we have already discussed installation and running tests on mobile chrome browser so before reading this article it is must to complete the previous post.

 

Once you are done you need to download the apk file which you want to test.

In Android application extension is .apk file.

In IOS application extension is .ipa file. 

 

I have uploaded the same tutorial on YouTube

 

 

 Steps to Automate Native application using Appium

 

  • Download .apk file for android device
  • Install in your device using ADB
  • Set .apk file in Appium and get the details about application which is required to run your test.
  • Write a test to launch the application on real device
  • Perform some action on application. (We will perform sendkeys i.e typing)

 

 

Download .apk file Appium

 

I have found an easy application which contains almost all kind of web elements.

Visit http://selendroid.io/setup.html and download .apk  file.

 

Download apk file for testing

 

 

Make sure Appium server is off.

Click on Android ICON.

 

Check the checkbox before application path

Browse the .apk file which we downloaded at 1st step.

 

Run the Appium server

Click on Android ICON.

Copy Package and Launch activity.

 

Appium-Settings

 

 

We need to deploy application in our local device as well.

Open cmd

Type  > adb devices

This will display the device which is connected.

 

Type > adb install give-apk-file-path-with-application

 

Application_deployed

 

 

Once it is deployed to your  device you will get a success message.

 

Android-App

 

 

 Program to automate Native application using Appium

 

package demo;

import io.appium.java_client.android.AndroidDriver;

import java.io.File;

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 StartApplication {

                             
// create global variable

private static AndroidDriver driver;

public static void main(String[] args) throws MalformedURLException, InterruptedException 
{


 // Create object of DesiredCapabilities class                             

DesiredCapabilities capabilities = new DesiredCapabilities();



// Optional

capabilities.setCapability(CapabilityType.BROWSER_NAME, "");


// Specify the device name (any name)

capabilities.setCapability("deviceName", "My New Phone");


// Platform version

capabilities.setCapability("platformVersion", "4.4.2");


// platform name

capabilities.setCapability("platformName", "Android");


// specify the application package that we copied from appium                

capabilities.setCapability("appPackage", "io.selendroid.testapp");


// specify the application activity that we copied from appium                   

capabilities.setCapability("appActivity", ".HomeScreenActivity");

 
// Start android driver I used 4727 port by default it will be 4723

driver = new AndroidDriver(new URL("http://127.0.0.1:4727/wd/hub"), capabilities);



// Specify the implicit wait of 5 second

driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);



// Enter the text in textbox

driver.findElement(By.xpath("//android.widget.EditText[@content-desc='my_text_fieldCD']")).sendKeys("Mukesh Selenium Appium");


// click on registration button  
                                   
driver.findElement(By.id("io.selendroid.testapp:id/startUserRegistration")).click();



// Wait for 10 second

Thread.sleep(10000);



// close the application
 driver.quit();



                }



}

 

 

Run the program and enjoy the native test automation.

 

This is just a small program just to make sure everything is up and running.

I took very basic application to automate Native application using Appium but you can take any application and perform the same step.

 

In next article I will cover how you can perform other activity on application using xpath and other ways.

If you liked this article then please share with your friends or team.

 

Feel free to comment in case any issue.

 

You can like our Facebook Page for more updates Learn Automation Page
Join our facebook group for any query Selenium Group Discussion

 

 

 

 

Filed Under: Appium Tutorials Tagged With: Test Mobile Application

Reader Interactions

Comments

  1. Roshni D. says

    March 16, 2022 at 2:32 PM

    Hi Mukesh,

    Thanks for your videos,
    Can you please help how to hit the mobile application via Proxy ? I need a help to implement the proxy for Mobile App.

    Reply
    • Mukesh Otwani says

      March 17, 2022 at 12:16 PM

      Hi Roshni, you can use Proxy class from Selenium and then use the same for AppiumDriver.

      Reply
  2. Akash says

    August 7, 2019 at 11:55 AM

    Hi Mukesh, I am referring your tutorial in 2019, can you do one more video on mobile testing with latest android version, latest appium version and NOX android emulator.

    Reply
    • Mukesh Otwani says

      August 7, 2019 at 12:26 PM

      Sure Akash…:)

      Reply
  3. rajatouseef says

    February 13, 2017 at 4:57 PM

    videos are awesome
    waiting for next video how you get x path and id
    in native app.
    thanks mukesh

    Reply
    • Mukesh Otwani says

      February 13, 2017 at 9:16 PM

      Hi there,

      Very soon I’ll post it.

      Reply
  4. Pradeep B B says

    January 6, 2017 at 11:56 AM

    In Appium framework, Package and Launch activity is blank even though I checked d check box, can you please help me, bt sample selendroid.apk is installed in my device

    Reply
  5. thulashi says

    January 2, 2017 at 11:42 AM

    Thank you Mukesh, its really helpful

    Reply
  6. jayesh says

    December 6, 2016 at 2:48 AM

    Thanks

    Reply
  7. jayesh says

    December 6, 2016 at 2:43 AM

    Hi Mukesh…Thanks for your excellent tutorial & documention…I have been following this for long time. I need your suggestion in one place where I stuck..I alreday posted the issue in slack and some forums –[http://stackoverflow.com/questions/40643411/appium-webview-switch-not-working-in-ubuntu] can you please this link and help

    Reply
    • Mukesh Otwani says

      December 6, 2016 at 12:04 PM

      No idea about Linux 🙁

      Reply
  8. Anjali Kashyap says

    November 20, 2016 at 2:20 PM

    Hi mukesh,
    While running the program you mentioned in your post, I got below error:
    Failed to start an Appium session, err was: Error: ‘java -version’ failed. Error: spawn ENOENT

    Reply
    • Mukesh Otwani says

      November 23, 2016 at 3:10 PM

      Hi Anjali,

      Is this fixed? Kindly update appium to latest version and run the same code again.

      Reply
  9. Richa Shrivastava says

    October 18, 2016 at 4:13 PM

    Hi Mukesh,

    I am using windows machine currently
    If I want to test on my app on iphone then can I simply change something in above script and run it? OR I have to setup everything on Mac machine?

    Reply
    • Mukesh Otwani says

      October 18, 2016 at 4:31 PM

      Hi Richa,

      You need mac machine in order to run or test IOS app.

      Below video will help

      If you dont have MAC then check below video

      Reply
  10. Lokesh says

    September 23, 2016 at 6:31 AM

    Hi Mukesh,
    I have been following you on youtube videos and they are good.I like the way you have explained it and the communication is the key.

    I am at automation engineer been working on Appium, I am stuck with doing scroll on Mobile Apps for both iOS and Android, will be helpful if you could link me to those videos on how to do it, or give me an example for any app which it is implemented and working fine.

    Or else if you could help me i can share you the .apk/.ipa file of the App which i am working on.

    Look forward to hear back from you.

    Regards,
    Lokesh

    Reply
    • Mukesh Otwani says

      September 29, 2016 at 2:33 PM

      Hi Lokesh,

      Note- Kindly use java-client jar less than 4.0 version then only below post will help.

      Below post will work

      http://learn-automation.com/scroll-in-appium-for-android-and-ios/

      Reply
  11. Ankur Gupta says

    August 29, 2016 at 11:05 PM

    Hi Mukesh,

    I would like to say thank you for the all videos you have uploaded till now. Videos are totally awesome. You have explained small to small very clearly.
    Please upload some more videos on Appium tool. This is my request to you.

    Reply
    • Mukesh Otwani says

      September 8, 2016 at 1:28 AM

      Hey Ankur,

      Thanks 🙂 yes Appium videos are in pipeline so will upload soon

      Reply
  12. santosh singh says

    July 8, 2016 at 3:32 PM

    Hi Mukesh,
    i am new in appium and learn lot of concept from your site ,some confusion i am craeate script for mobile Automation but some time i am my appium server is not start so what can i do and i am wriing all functionality code but some time it works and some time it fails.
    package gotuktuk;

    import java.io.File;
    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;
    import org.openqa.selenium.remote.RemoteWebDriver;

    import io.appium.java_client.android.AndroidDriver;

    public class StartApplication {

    private static RemoteWebDriver driver;

    public static String phoneNum = “9926895346”;
    public static String pickUpAdd = “Corporate House, Rabindranath Tagore Marg, Chhoti Gwaltoli, Indore, Madhya Pradesh”;
    public static String dropAdd = “301/4 Nehru Nagar, Patni Pura Indore, Madhya Pradesh 452001”;

    public static void main(String[] args) throws MalformedURLException, InterruptedException {
    System.out.println(“**************************start***********************************”);
    File classpathRoot = new File(System.getProperty(“user.dir”));
    System.out.println(“USER DIR : “+System.getProperty(“user.dir”));
    File appDir = new File(classpathRoot, “/Android/data/”);
    File app = new File(appDir, “RIDER.apk”);

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, ” “);
    capabilities.setCapability(“deviceName”, “Galaxy j5(2016)”);
    capabilities.setCapability(“platformVersion”, “6.0.1”);
    capabilities.setCapability(“platformName”, “Android”);
    capabilities.setCapability(“app”, app.getAbsolutePath());
    capabilities.setCapability(“appPackage”, “in.gotuktuk.rider”);
    //capabilities.setCapability(“appActivity”, “com.tuktuk.corelib.ui.activity.LogoSplashActivity”);
    driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
    driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);

    //Thread.sleep(4000);
    setPhoneNumber(phoneNum);
    Thread.sleep(20000);
    getMenu();
    // Thread.sleep(20000);
    // getHistory();
    // Thread.sleep(5000);
    // getRateCard();

    //setCurrentPickupLocation(pickUpAdd);
    //seeRateCard(dropAdd);

    // driver.quit();
    System.out.println(“**********************************End***********************************”);
    }

    private static void setPhoneNumber(String phoneNum2) {
    // TODO Auto-generated method stub
    System.out.println(“==>Entering phone number ..”);
    driver.findElement(By.id(“in.gotuktuk.rider:id/phoneNumberEditText”)).sendKeys(phoneNum2);
    driver.findElement(By.id(“in.gotuktuk.rider:id/verifySMSButton”)).click();
    System.out.println(“==>Clicked on Button ..”);
    }

    private static void seeRateCard(String dropAdd2) throws InterruptedException {
    // TODO Auto-generated method stub
    System.out.println(“==>Entering drop address ..”);
    driver.findElement(By.className(“android.widget.RelativeLayout”)).findElements(By.id(“0”));
    Thread.sleep(5000);
    driver.findElement(By.id(“in.gotuktuk.rider:id/staticComponentDropAddressTextView”)).getAttribute(dropAdd2);
    System.out.println(“==>Clicked on Rate Card Button ..”);
    }

    private static void setCurrentPickupLocation(String pickUpAdd2) throws InterruptedException {
    // TODO Auto-generated method stub
    System.out.println(“==>Setting current address ..”);
    driver.findElement(By.id(“in.gotuktuk.rider:id/myLocationImageView”)).click();
    Thread.sleep(2000);
    //driver.findElement(By.id(“in.gotuktuk.rider:id/bookingButtonActionEnableTextView”)).click();
    System.out.println(“==>Clicked on Button ..”);
    }

    private static void getMenu() throws InterruptedException {
    // TODO Auto-generated method stub
    //Thread.sleep(3000);
    System.out.println(“==>in get menu ..”);
    driver.findElement(By.className(“android.widget.ImageButton”)).click();
    Thread.sleep(7000);
    System.out.println(“==>Clicking on History ..”);
    driver.findElement(By.name(“HISTORY”)).click();
    Thread.sleep(3000);
    driver.findElement(By.className(“android.support.v7.app.ActionBar$Tab”)).click();
    Thread.sleep(5000);
    System.out.println(“==>Back button from history ..”);
    driver.findElement(By.className(“android.widget.ImageButton”)).click();
    Thread.sleep(5000);
    driver.findElement(By.className(“android.widget.ImageButton”)).click();
    Thread.sleep(5000);
    System.out.println(“==>Clicking on tCash ..”);
    driver.findElement(By.name(“tCASH”)).click();
    System.out.println(“==>Clicking on SHARE REFERRAL CODE ..”);
    Thread.sleep(3000);
    //driver.findElement(By.id(“in.gotuktuk.rider:id/tCashSocialMediaShareView”)).click();
    System.out.println(“==>Back button from refereal code ..”);
    driver.findElement(By.className(“android.widget.ImageButton”)).click();
    //driver.findElement(By.className(“android.widget.ImageButton”)).click();
    driver.findElement(By.className(“in.gotuktuk.rider:id/menu_row_name”)).click();
    }

    private static void getHistory() {
    // TODO Auto-generated method stub
    driver.findElement(By.id(“in.gotuktuk.rider:id/menu_row_icon”)).click();
    }

    private static void getRateCard() {
    // TODO Auto-generated method stub
    driver.findElement(By.className(“in.gotuktuk.rider:id/menu_row_icon”)).click();
    }
    private static void Notification() {
    // TODO Auto-generated method stub
    System.out.println(“==>Back button from refereal code ..”);

    driver.findElement(By.className(“in.gotuktuk.rider:id/menu_row_name”)).click();
    driver.quit();
    }
    }
    so can you share me this type of solution

    Reply
    • Mukesh Otwani says

      July 12, 2016 at 5:00 PM

      Hey Santosh,

      We need to find out the pattern and then we need to make changes. Run multiple time and when it fails try to collect logs, then only we can make the changes.

      Reply
  13. cg says

    March 27, 2016 at 12:54 PM

    Hello! Awesome tutorials! I was wondering how to integrate appium with jenkins? Also what if you don’t have a local jenkins server? Thanks!

    Reply
    • Mukesh Otwani says

      March 27, 2016 at 9:04 PM

      Hi CG,

      Thanks for nice feedback.

      Process to integrate with jenkins will be same.

      Kindly refer below link

      http://learn-automation.com/selenium-integration-with-jenkins/

      If Jenkins is on server then you need to create slave on local machine then you can trigger the test.

      Reply
  14. Suresh Shaw says

    March 23, 2016 at 3:09 PM

    Gr8 article Mukesh. Thanks. Plz tell me how to take xpath in mobile native app

    Reply
    • Mukesh Otwani says

      March 26, 2016 at 1:58 PM

      Hi Suresh,

      Below article will explain you the same

      http://toolsqa.com/mobile-automation/appium/findelement-and-findelements-commands/

      Reply
  15. Nil says

    December 30, 2015 at 4:01 PM

    Can you tell me how to use Appium inspector in windows 7

    Reply
    • Mukesh Otwani says

      January 2, 2016 at 10:46 PM

      Hi Nil,

      I use UIAutomateViewer to inspect the elements.

      Reply
  16. Yuval says

    December 23, 2015 at 12:56 AM

    Thank you for sharing this information, I also shared this with your links and name at http://www.qatestingtools.com/testing-tool-article/Automate%20Mobile%20native%20application
    will be happy to share of your articles

    Reply
    • Mukesh Otwani says

      December 23, 2015 at 3:42 PM

      Thanks Yuval

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Free Selenium Videos

https://www.youtube.com/watch?v=w_iPCT1ETO4

Search topic

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?

Stay connected via Facebook

Stay connected via Facebook

Archives

Footer

Categories

Recent Post

  • Syllabus For Playwright Online Training Program
  • API Testing Using Postman And RestAssured
  • Disable Personalise Your Web Experience Microsoft Edge Prompt In Selenium
  • How To Fix Error: No tests found In Playwright
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?