Setting up Appium for testing on real devices for android app automation can be tricky. Many testers struggle with installing the right software, setting environment variables, and connecting their devices properly. These issues can cause a lot of frustration and slow down the testing process.
In this blog, we’ll make it easy for you. We’ll walk you through each step, from installing necessary software like the Java Development Kit (JDK) and Android Studio, to setting up your Android device for android app automation. We’ll also show you how to install Appium, configure it correctly, and use tools like Appium Inspector to interact with your app.
By following this simple guide, you’ll be ready to test your mobile apps on real devices quickly and efficiently.
What is Appium testing in Android App Automation
Appium is an open-source automation tool used for testing mobile applications. It allows testers to automate native, hybrid, and mobile web applications on iOS and Android platforms using the WebDriver protocol. Appium provides a unified API (Application Programming Interface) that allows you to write tests using your preferred programming language (such as Java, Python, JavaScript, etc.) and test frameworks. It supports a wide range of automation capabilities, including gestures, device rotation, multi-touch actions, and handling various types of mobile elements. Appium enables cross-platform testing, where the same tests can be executed on multiple devices, operating systems, and versions, providing flexibility and scalability in mobile app testing or android testing.
Advantages of Using Appium in Android App Automation:
- Appium is an open source and free tool available for testers and developers.
- Appium supports both real device and emulators/simulators testing.
- Appium is compatible with popular testing frameworks and tools, making it easy to integrate into existing testing workflows and environments.
Advantages of using real device for Android App Automation:
- Real device allows you to check your application under different network like 2G,3G,4G and 5G.
- Using real device we can test hardware specific features like GPS, fingerprint and camera.
- Using a real device provides more accuracy by taking some factors into consideration like device battery, processor, memory and device size.
Step→1
Install Java Development Kit (JDK):
- Download and install the latest JDK from the official Oracle website.
- Set JAVA_HOME as environment variable.
- Also add jdk’s bin folder path in Path environment variable.
Step→2
Install Android Studio:
- Download and install Android Studio from the official Android website.
- After successful installation now we will set the ANDROID_HOME environment variable.
- Also put platform tools path in path variable.
- Now open cmd and run adb in command line and it should get executed successfully.
Step→3
Install Node.js:
- If you haven’t already installed Node.js, you can download and install it from the official Node.js website.
- Once the installation is complete check node version using command node -v also npm -v.
Step→4
Install Appium for real device testing using command npm install -g appium in command line:
- Verify appium version using appium -v in command line.
- Now run the command appium in command line using this command your server should start and we are ready to do testing.
Step→5
Install Appium for real device testing using command npm install -g appium in command line:
- Now run appium-doctor in command line to check weather every dependency required for appium has been installed successfully.
Step→6
Now we need to install UIAutomator driver which allows to interact with the UI elements of Android apps during automated testing. It provides improved stability and performance compared to the original UIAutomator driver. To install it use this command appium driver install uiautomator2 in command line.
Step→7
Now for real device testing we also need to make some changes on device side too so we need to enable developer option for this:
- Open setting and click on about phone.
- Click on software information.
- Click on Build number 5 times to enable developer mode.
- Now once this option is enabled we need to enable usb debugging option as well.
Note: Above information to enable the developer mode its for SAMSUNG device it will be different for other device type.
What is Appium Inspector in Android App Testing?
Appium inspector is a tool which provides testers with a graphical user interface for inspecting and interacting with elements within mobile applications.
Step→8
Install appium inspector for windows using below link appium inspector.
Step→9
Start the appium session using command appium -a 127.0.0.1 -p 4723
- Alternatively we can use appium GUI Appium GUI to start the server
i. Enter the host as 127.0.0.1
ii. Enter port number as 4723
iii. If you are using Appium GUI for start server.we need to also add remote path for Appium inspector
Step→10
Open the appium inspector enter remote host as 127.0.0.1 and port as 4723.
Configuring Desired Capabilities using Appium for Android App Automation:
When setting up automation with Appium for Android devices, it’s crucial to define the desired capabilities appropriately. These capabilities act as parameters that instruct Appium on how to interact with the device and the application under test.
deviceName: This parameter specifies the name of the device being used for testing. It’s essential to provide an accurate device name to ensure that Appium connects to the correct device.
udid: The Unique Device Identifier (UDID) uniquely identifies the device among all others. Appium uses this identifier to target the specific device for automation. Make sure to input the correct UDID of the device you intend to automate.
platformName: Here, the platform name is set to “Android,” indicating that the automation is targeted towards the Android platform.
platformVersion: This parameter denotes the version of the Android platform installed on the device.
automationName: Appium supports multiple automation frameworks, and here, “UiAutomator2” is specified as the automation name. UiAutomator2 is a widely used automation framework for testing Android apps.
appPackage: The app package is the unique identifier for the application under test. It’s essential for Appium to know which app to launch and interact with during automation.
appActivity: This parameter specifies the main activity of the application that needs to be launched.
- For device udid run adb device command in command line
- For device name and version we can check software information from android settings
- For application package and appActivity we can download Apk Info application from play store
- For application bundle Id and App activity
Step→11
Once you enter the remote host and port number enter below capabilities to open calculator application from your android devic for android testing.
{
"appium:deviceName": "your device name",
"appium:udid": "device udid",
"platformName": "Android",
"appium:platformVersion": "Android version",
"appium:automationName": "UiAutomator2",
"appium:appPackage": "com.sec.android.app.popupcalculator",
"appium:appActivity": "com.sec.android.app.popupcalculator.Calculator"
}
The images below illustrate how I started the Appium server using the Appium GUI and successfully opened the Calculator app in Appium Inspector with the specified capabilities and now it’s ready to inspect your app to prepare for automated testing efficiently.
Conclusion:
Setting up Appium for testing on real Android devices can initially seem daunting due to the numerous steps involved and the technical nuances of configuring software and environment variables. However, by following this step-by-step guide, the process becomes manageable and straightforward.
Investing the time and effort to configure Appium correctly pays off by significantly enhancing the efficiency and effectiveness of your mobile testing strategy. This setup not only improves the
Click here for more blogs of software testing and test automation.
3Junior Software Development Engineer in Test (JR. SDET) with 1 year of hands-on experience in automating and testing mobile applications using Python and Appium. Proficient in Selenium and Java, with a solid understanding of real device testing on both iOS and Android platforms. Adept at ensuring the quality and performance of applications through thorough manual and automated testing. Skilled in SQL and API testing using Postman.