step towards mobile automation….
Have you always wanted to get into mobile test automation space but was reluctant thinking you have no clue where to start?
Then here you go , a simple article outlining how to setup android emulator and find the locators for the elements using Appium desktop app and Android studio
(The Android Emulator simulates Android devices on your computer so that you can test your application on a variety of devices and Android API levels without needing to have each physical device)
Install Android Studio:
This has the emulator .
Note: you might get an error at the end saying cannot open correctly follow the below step
Open Android studio:
In windows go to the installation folder and open
android studio/bin and double click studio.bat
Change the Target of your android studio
Install SDK in android studio:
click SDK manager:
Select the desired SDK android version and click apply.
This will install the SDK:
Set Environment Variables:
goto windows and type edit environment variables and this two environment variable
Add the value as the path to which SDK is installed
Also add D:\MyProjects\Appium\Sdk\platform-tools to PATH
Configure emulator (Virtual device):
Click AVD Manager
Configure the device as you want and at the end use graphics as software ( use hardware only if you have a graphic card)
Hyper-V is a virtualization feature of Windows that makes it possible to run virtualized computer systems on a physical host computer. Intel’s Hardware Accelerated Execution Manager (HAXM). HAXM is a virtualization engine for computers running Intel CPUs.
Install system image:
Click play to start the simulator and then power it own:
If you get abd not found error then goto sdk installation folder delete sdk folder , reinstall sdk by going to sdk manager and select new sdk installation path
Goto File>Profile or APK Debug (select Create a newfolder if prompted)
Now goto File > Project structure and
install jdk and select project sdk
To verify that all of Appium’s dependencies are met you can use
appium-doctor. Install it with
npm install -g appium-doctor, then run the
appium-doctor command, supplying the
--android flags to verify that all of the dependencies are set up correctly.
Check if device is find by adb driver:
ADB is a command line tool that allows users to control their Android device on their Windows PC, This is like usb driver which allows windows to detect the mobile device.
to check if the emulator is detected by the driver use below command
Appium and Appium studio :
Appium allows to interact with mobile drivers and through that to the device or emulator
It also has inbuild inspector to inspect the elements locators
Find the build with tag latest , download
the windows version
Install appium using npm:
you can also use appium as command line tool using npm , but you need appium studio to inspect elements anyways.
npm install -g appium
Start Appium studio:
click start server
Open element inspect:
Now add the capability:
click save. and then click start session
Eg capabilities : here we are telling the apk of the app we are testing and all other information.
"appium:deviceName": "Android Emulator",
After starting session , inspect elements:
use the select element to find the locator and use red mark option to click any element,
Other buttons are self exploratory can be used to navigate through different views.
IF you want to goto another page just navigate to that page in emulator and click the refresh button 5th icon from left
Finding Current activity locator: ( Thanks to testsigma.com)
Activity is like url in web automation , you can use activity to navigate to a specific page in the app.
in windows use below command:
adb shell dumpsys window | find "mCurrentFocus"
in linux/mac :
adb shell dumpsys window | grep -E 'mCurrentFocus'
The blue marked part after u0 is the package name and the remaining section is the activity name
In the coming articles we will see how to use this information in the web autoamtion: