
Appium tool is an open source, cross-platform automation testing tool and therefore we use appium tool in testing native applications, mobile-web applications and hybrid applications using a webDriver.
The tool majorly focus on both Android and ios apps and only restricted to the mobile application testing domain.
So we will start with getting the environment set up, Appium tool installed and running it on your machine.
Pre-requisties
Downloading and Installing below softwares
- Install the Java Development Kit (JDK)
- Appium (http://appium.io/downloads.html)
- Android Sdk manager (https://developer.android.com/studio)
- Node js (https://nodejs.org/en/download/)
Set System Variables
- Set up Java Environment Variable PathSet the path till JDK bin. https://www.javatpoint.com/how-to-set-path-in-java
- Setting the path for android sdk. Make an Android Home variable and set the path till android sdk.
ANDROID_HOME “c:/android-sdk
Steps to setup APPIUM and device :
1.We have download and installed android sdk manager.
2.To know if sdk has installed correctly write“adb “command.
If it is installed correctly,the command will run successfully.
3. Go to Tools in android sdk folder and extract the platform- tools by going to cmd and entering the command:
sdkmanager “platform-tools” “platforms;android-28”
*note 28 refers to the compatibleversion of your Android.
We can also install the Android Studio to download the platform –tools and other dependencies.
4. Open and connect your phone by turning on Developer option.
It can be done by by clicking on 7 Times on the mode and then swipe on the usb debugging mode to turn it on.
5. We have installed appium desktop ,now you will see below screen start server.

6.Click on start server ,we can see it running.

Write Appium Test Script to launch play store app
The different capabilities such as udid,device name,platform version,platform name refers to the device we are testing.
Given below are the commands to extract the values for these capabilities.
"full-reset": "false"
"udid":"44c69f360503"( adb device number in cmd)
"deviceName": "Redmi"
"platformVersion": "7.0"
"platformName": "Android"
"appPackage": "com.android.vending" "appActivity":"com.google.android.finsky.activities.MainActivity"
Find out device name and udid of the mobile device:
Write adb device and we can have device name and its device number for adding it in capabilities as device name and UDID.
Find out appPackage and appActivity names of the mobile app:
Open the app you want to launch through automation in your phone .
Write command adb shell and then dumpsys window windows | grep -E ‘mCurrentFocus’

Start the appium server.
Write the following code to test that we are able to launch the app through script.
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
public class AppiumTest {
public static void main(String[] args) {
//Set the Desired Capabilities
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "My Phone");
caps.setCapability("udid", "ENUL6303030010"); //Give Device ID of your mobile phone
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "6.0");
caps.setCapability("appPackage", "com.android.vending");
caps.setCapability("appActivity", "com.google.android.finsky.activities.MainActivity");
caps.setCapability("noReset", "true");
//Instantiate Appium Driver
try {
AppiumDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), caps);
} catch (MalformedURLException e) {
System.out.println(e.getMessage());
}
}
}
Your script would start running and you would see that Play Store app would get launched on your mobile device. This entire process might take 10-15 seconds because Appium has to connect to your mobile device first. A good approach would be to run your script and then monitor the Appium Desktop screen. You would notice that Appium Desktop screen should start showing some logs. This way you will know that your Appium test script is running.
For emulator you can just create the emulator using android studio. https://developers.foxitsoftware.com/kb/article/create-an-emulator-for-testing-in-android-studio/
Add it in capabilities device name and udid using adb command.

You will be able to launch the app in emulator as well successfully.

Debugging: Following are the errors you can face while set up and installation of Appium.
Error: Unable to connect to server.
1.Ensure “Allow for local internet Automatic server is there and hence check the “Allow Unathorised Certificates” for appium version 1.6*.
2.Go in Custom Server tab then enter Remote host: 127.0.0.1 Remote port: 4723 and then go to Advance Setting link and tick the check box“Allow Unauthorised Certificates the”and desired capability then start the session.
Error: Unable to find build tool folder.
Create a dummy Folder With the name of Build tool at the below location
C:\sdk-tools-windows-4333796\build-tools
Error: Over ride session
- When you open Appium then navigate to the advanced tab instead of simple tab and then check “ALLOW SESSION OVERRIDE”.
References:
http://appium.io/docs/en/about-appium/getting-started/
