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

Appium and Image Recognition

Dear Testdroiders,

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 Testdroid Cloud 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 test scripts work well on different devices with the method of image recognition, you need to prepare images with different resolution.

Appium Tip #26

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.

Screen Shot 2016-08-10 at 15.20.27

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.

Screen Shot 2016-08-10 at 15.07.45

Screen Shot 2016-08-10 at 15.21.31

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’).

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 Java script 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 at Testdroid Cloud


The Beginner’s Guide of Using Appium for Mobile App Testing

Learn all the basics about Appium, how to set it up and how to use it for mobile app testing.

Download

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close