Mobile app testing by Appium :: Part 1

Prerequisites

  1. Need to install JDK 1.8 or higher (click if you don’t know)
  2. Install Android Studio
  3. Set the ANDROID_HOME in the windows environment variable
  4. Set the path properly

Then apply and ok everything

Now open the CMD with administrator privilege

type adb –version and hit enter.
If adb version shows, then you have perfectly setup android home environment

Download apk from the playstore

Let’s we will do automate a calculator apk that already installed on our android phone device. We have to know at first which apk we will do automate, that must be a debug apk.
I am going to automate this calculator app as this is a built-in debug apk

Go to the playstore and copy the link

https://play.google.com/store/apps/details?id=com.google.android.calculator

Then go to this link, paste your copied URL here and click on “Generate Download Link” button

Then click on green button and download the apk

Debug the apk

After downloading the apk, open it with Android Studio. If you do not have, download or update it.

Then select AndroidManifest.xml

We have to retrieve two main things here. 1. package name 2. Main Activity name

So, our app package name is: com.google.android.calculator and
Main app activity is: com.android.calculator2.Calculator

Install and configure Appium

Now download and install appium

If you do not have installed appium, then download it from here. If you are a windows user, download the .exe software

After downloading, install it. Keep the all default configuration.

Now start the Appium

After starting the service, you will see this

Connect the mobile device

Before connecting the mobile device, you must have to enable the “USB debugging” from the developer option.

Here is the process step by step:

  1. Go to settings
  2. Tap on “About phone”
  3. Tap three times on “Build number”
  4. Then you will become developer
  5. Then go to System
  6. You will find “Developer options”
  7. Tap on “Developer option”
  8. Enable “USB debugging”

Now connect your mobile device with your PC by USB

Allow the USB debugging from your mobile phone

Now start CMD with administrator privilege

Hit following command:

adb devices

You will get the UUID number if device connected properly with pc and allow USB debugging from the phone

Now go to your Appium

Click on the search icon

Input following texts as desired capabilities on the text boxes

Notice that we have already our appPackage and appActivity previously

On the right side, you will see a JSON body has been implemented automatically

Now save as the configuration named as “Calculator App”

You will find the saved configuration on “Saved Capability Sets”

Now Click on Start Session button

Make sure, your android phone is unlocked

Now you can see the calculator app has been launched and showing on your Appium

Inspect Elements

Click on any button and you will see the id and other properties that will be used to our automation script

about author

admin

salmansrabon@gmail.com

If you like my post or If you have any queries, do not hesitate to leave a comment.

Leave a Reply

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