Efficient UI testing series
- Local and Instrumentation tests in Android
- Android Studio and Android SDK tools
- UI Testing Frameworks
- Exploring "Espresso Test Recorder"
- First test case with Kakao framework
- Testing Android Fragment in isolation
- Exploring test application and first test cases
- A domain-specific language for testing
- Introducing UI tests with mocking
- Flaky tests
- Achieving efficiency in tests
Let us start with a tool which is a part of Android Studio; it is called "Layout Inspector". It's a powerful tool which allows us to compare mockups from a UI/UX team with a screen from our application. You can find information about each view on the screen. It means that we can use it for getting additional information about each view on the screen.
As Layout Inspector is a part of Android Studio, we should move to required screen on device or emulator and click "Tools -> Layout Inspector" in Android Studio. Next step is choosing a device/emulator. Afterwards, Layout Inspector captures a snapshot and saves it in
*.li file. It allows us to compare different versions of the screen from the app.
Note: If you want to capture screenshot from any application, you should install it on a rooted device or an emulator without Google Play. In this case, you should choose "Show All Processes" and select the required process.
Note: It's the reason why you can have additional
*.li files in the capture folder.
As you can see from the screenshot, visually, this tool has got 3 sections:
- View Tree provides a hierarchy of views in the layout;
- Interactive Screenshot shows a screenshot of your app with layout bounds of each view;
- Properties Table allows you to check any property connected with each view on the screen.
UI Automator Viewer
The UI Automator Viewer tool provides a screenshot of an active application on a device or emulator. We can scan and analyse a screen of any application which is installed on the device. This application is not a part of Android Studio; it means that we should run it from
As you can see, this tool splits into 3 sections: screenshot, view tree and properties table. These sections are the same as in case of "Layout Inspector" tool. However, we have not got too many properties in comparison with the Layout Inspector. However, we can scan any application from the device or emulator.
The Layout Inspector and UI Automator Viewer tools allow us to get the required information about views from a different screen in others application if you need this information.
Different parts of our application cannot be tested inside the application, like Notifications, App shortcuts, and so forth. We can use "UI Automator Viewer" for getting information about different applications (if we use not rooted device or emulator with Google Play, otherwise we can get information about any application use "Layout Inspector" and "UI Automator Viewer", like the launcher, to navigate to your application and verify app shortcuts feature for the developing application.
We can use these tools for getting information about views on the screen which can is needed for UI testing.