Appium Tip #26: Match Image Resolution with Device Screen Resolution

  August 10, 2016

Over the past year since we introduced how to use the technology of Image Recognition to run automated Appium tests for mobile games, we’ve noticed a skyrocketing amount of test runs on Bitbar Testing using image recognition for mobile game test automation. Today, we’d like to share another quick tip to any mobile game developers or QAs who are just new to the image recognition for mobile game testing. To make sure your Appium test scripts work well on different devices with the method of image recognition, you need to prepare images with different resolution.

Download Our Free Appium Beginner’s Guide to Consolidate Your Appium Setup and Testing Environment

If the images are too sharp in high resolution, they can possibly not be identified and found on low-resolution devices. This also applies to low-resolution images on high-resolution devices. And the rule of thumb here is that high-resolution images should be used to work on high-resolution devices (1920×1080), while the low-resolution images are for low-resolution devices (1280×720).

That being said, you can still try with one set of images with middle resolution in an attempt to work on both high resolution and low-resolution devices. But it depends on how big the differences are. Here’s one example that one set of images work for both device resolution. We used one set of query images.

appium image high resolution

Then we ran it on 5 different devices with different screen resolution, among which Acer Iconia Tab 8 has 1920×1200, Asus Google Nexus 7 has 1280×800, and the rest all have 1920×1080. The test itself went successfully.

appium test runs
appium image resolution on devices

However, games are different than each other. For HillClimbRacing, taking one set of images with middle-resolution work for different devices. It doesn’t mean that the same method works for you as well. Without the proper images, your tests will eventually fail. The best way to address that is to use two different sets of images for different screen resolutions.

For doing that, you need to take all the same images on a lower resolution device and have them in a separate folder (here we use ‘low_resolution_images’).

appium image low resolution

Once you are done with the images, you need to add code in your script so that these low-resolution images will be used when tests are running on low-resolution devices. For example, the added code in Javascript could look like

public void setQueryImageFolder() {
Dimension size = driver.manage().window().getSize();
log("Screen size: " + size.toString());
if ((size.getWidth() <= 520) || (size.getHeight() <= 520)) {
screenshotsFolder = "low_resolution_images";

Change the value of size.getWidth and size.getHeight accordingly based on your targeted devices.

Hope this Appium Tip would help you succeed in image recognition for mobile game testing.

Happy testing with Appium and Image Recognition