Monitor battery usage programmatically

I want to be able to monitor the battery usage when running automated test cases with appium. For example like get the current battery level before running a series of test and then get the battery usage after text execution has finished. The end goal would be to get some kind of metrics on how much battery our application uses.

Is this possible with latest version of appium?
If not, does apple provide a way to do this? Possible feature request.

Has anyone else every done this type of battery testing before?

1 Like

But won’t your device be plugged in so that Appium can access it? If the device is constantly charging, what metrics do you expect to find?

you should use appropriate DC power monitor instead. we used similar to: .
1 there is software that recording all power consumption supplied by DC power monitor producer
2 you have some app under test leaving for night or whole day

we tested work of our mail client in real network and WiFi. if you need some work to be done on client you should think or make note that client that forces your app to do something will also user power and thus your real usage not correct.

I was hoping for battery usage metrics, like your iPhone will tell you the battery usage of different apps. I was hoping to be able to access that information some how. I understand that the usage won’t be accurate because appium driving the automation will probably use up battery as well, but that is better than nothing.

I didn’t really have high hopes for finding a solution, but I figured I would post this in case anybody else has attempted something like this before.

It’s absolutely a good idea to test, I’m just not confident that Appium is a good tool to use for this. Thanks @Aleksei for the power monitor link. I may try for a similar kind of setup. Like a ‘Kill-a-Watt’ for mobile.

this is 300% inaccurate. like on Android also. They all based on battery voltage down while it is discharging. Which never was any accurate. moreover - it cannot tell when you have any power loss spikes.