Mobile testing is a very hot topic nowadays. There are two ways to test how the application is interacting with the user on the mobile device one is manually and the other is through automation.
Manual testing takes lot of time and it’s a very slow process. While automation testing is more efficient and effective process. In automation testing we have to write the test cases to cover the specific scenarios and then run those test cases automatically. While we are writing the test cases, we have to identify the objects, and for this we use UIAutomator VIEWER.
Appium uses UIAutomator VIEWER.
Appium is an open source mobile automation tool which is useful to automate android and IOS platform apps. It support Native, Hybrid and Web Application.
How to use UIAutomator VIEWER
UIAutomator Viewer is a GUI tool that comes with Android SDK. It is used to examine and inspect the UI components of an Android Application that are visible on the forefront of the device.
- Install the android SDK. When the SDK has been installed in the system, you have to move that SDK folder from C Drive to another Drive suppose E Drive.
- Under SDK folder, go to SDK then go to the Tool Folder. Double click on UIAutomator viewer batch file to launch it
You will find uiautomatorviewer.bat file in Tools folder of SDK. e.g. E:\SDK\tools.
- Attach your device with your PC using USB cable.
- Verify the device is connected to the system by using adb devices command on CMD prompt.
- Enable the developer option in the Android Device from the Settings.
- Select LinkedIn application.
- Click on the device screenshot button and the LinkedIn application opens up.
How to identify elements for automation
- text attribute can be used as “name” findElement(By.name(“Sign in”));
- resource-id attribute can be used as “id” findElement(By.id(“com.linkedin.android:id/login_button”));
- class attribute can be used as “className” findElement(By.className(“android.widget.Button”));
Challenges with the tool and there resolution
- To use UIAutomator VIEWER please make sure Android SDK is installed in the laptop.
- UIAutomator VIEWER does not support WebView. Firebug is used to identify the objects.
- Works on Android Devices with Version 4.1 (or higher).If you want to test UI on lower versions of Android Devices with Version2, use ‘Espresso’.
- When the mobile device is not connected to the PC and the user click on the ‘Device Screenshot’ button on top right corner of the screen, an error will occur “No Android devices were detected by adb”.
Comparison between UIAutomator Viewer and Calabash
- UIAutomator Viewer only works on API level 16 and above which means you can’t run your test on older devices while Calabash works on API level 8 and above.
- Unlike Calabash, UIAutomator Viewer runs on your computer which is driven by a server on the device that interacts with the app.