Application Data and Battery usage by mobile applications is an important factor for Mobile users. In the era of using mobile apps that support push notifications and data sync (Gmail, official twitter and facebook apps, UEM client, Gmaps) or using apps set to check every x minutes for accounts to get near-immediate notifications (email clients) ends up consuming more data and battery on devices
As App Developers we are constantly striving to provide a mobile application on a device that will impact very minimally on data and battery usage and will help users have a real time sync of any data.
There are multiple ways to perform Data Usage and Battery testing, there are many applications available to test this, but the most important challenge is the process of testing. Testing can be very time consuming as many of the applications will need hourly consumption checks, or idle time consumption checks over a period.
In order to overcome the testing challenges we came up with an automation set up to measure our battery, data usage using Selenium and Appium in single test scripts.
Selenium is for automating web applications and on the other hand, Appium is an open source test automation framework for use with native, hybrid and mobile web apps.
Any app that supports push notifications or data sync typically includes a server component, which sends out commands to a client, A client component, which runs on the device and receives and implements the commands, in our implementation we have integrated Selenium and Appium Scripts to perform actions on web application and client as a continuous process, creating and sending the command from the server to the client is automated through Selenium scripts, and on receiving the command on the device, Appium scripts capture the battery and data usage before and after the command has been executed from the Application settings, this is repeated for several commands and measured, baselined and optimized.
Integration of Selenium with Appium for Battery and Data Usage testing
Metrics to measure and Optimize Battery\Data Usage Testing
Data Usage & Battery Usage metrics differ for each product. Defining a good process for designing, measuring, baselining, and reporting plays a key role here. Some of the important metrics that should be measured are listed below:
- Idle conditions – Capturing the Data and Battery consumption when no actions are performed on the app is very important as most of the time this would be the use case
- Install the application on the Device, Record the initial data usage
- Allow the device to stay in idle condition i.e no user actions to be performed
- Record the data and battery consumption values every hour
- Both “before and after” data usage needs to be recorded in the reports for comparison and consumption analysis – This needs to be repeated over a period of time
- This process will help detect any unnecessary data or battery leakage.
- Operations or Functionalities – Similarly, for important functionalities, an hourly check during the operations will be a good metric.
- Network Conditions – Data usage testing needs to be performed on different network conditions (WiFi, 2G, 3G. 4G, Roaming) which means the same tests needs to be repeated under all conditions.
- Automation makes this whole process very easy to test and report the metrics.