Seeding an Android Device with Test Photos

February 23, 2026 · 10 min read · Mobile Testing

HeadSpin Platform
Automated & amp; manual examination create easy through data skill perceptivity.
Differentiating capabilities:
  • Extensive end-to-end automation of QA process
  • Comparative analysis of app execution against peers
  • Continuous monitoring of app execution using synthetic data for higher availability of apps
  • Easy-to-use developer friendly platform
cloudtest go
Affordable Existent Device Testing for Emerging Teams
cloudtest go
Affordable Real Device Testing for Digital Enterprises
cloudtest go
The Ultimate Solution for a Powerful Blend of Functional & amp; Performance Testing!
cyol
TEM
New
Centralized mobile test executing in cloud
cyol
Enhance Your Accessibility Testing With HeadSpin
cyol
Automate camera-based testing

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

retail

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

Seeding an Android device with test photosSeeding an Android device with test photos

Seeding an Android Device with Test Photos

Published on
January 24, 2018
Updated on
Published on
June 19, 2022
Updated on
 by 
 Jonathan LippsJonathan Lipps
Jonathan Lipps

As promised, this week & # x27; s edition is an Android-flavored follow-up to final week & # x27; s tip on. The problem we & # x27; re trying to solve is how to get pictures with known content onto the device for use in our App Under Test. This is a requirement for any eccentric of app that employ or processes persona.

How do you essay that your app does the correct thing to a user-provided image?

  1. Take some image you have dwell around, and input it manually to your application.
  2. Manually run the app use on your image. Maybe this is employ a sure type of filter, for example.
  3. Still manually, extract the limited image from your app any way you can (texting it to yourself, for model!)

What these steps do is provide a gold-standard before-and-after which you can use as a test fixture. In an machine-driven fashion now, we can provide the app with the same initial picture, run the desired map, and then regain the modified image. We can verify this modified icon is byte-for-byte eq to our gold standard to ensure the app functionality withal work as expected.

SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses.

Test your Android apps on real outside devices seamlessly..

In this edition we focus on the problem of getting our initial picture onto the twist. How make one do this for Android? Happily, we use the like function as for iOS:pushFile. Under the hoodlum,pushFile uses a serial ofADB commands to shuffle the picture to the gimmick and then broadcast a scheme intent to refresh the medium library. Since different twist manufacturers put painting in different places, you do need to know the path on your device that stores media. For emulators and at least some real devices, the path on the device is/mnt/sdcard/Pictures, so this is an important constant to your remember. As an exemplar:

driver.pushFile (`` /mnt/sdcard/Pictures/myPhoto.jpg '', `` /path/to/photo/locally/myPhoto.jpg '');

As you can see, the inaugural argument is the removed route on the device where we need the picture to end up. This is where you may need to relate to documentation on your particular twist or Android OS look to ensure you have the right itinerary. The second disputation is the path to the file on your local machine, where your test is running. When the tryout executes, the Appium client will encode this file as a twine and send it over to the Appium host, which will so do the job of getting it on the device. This architecture is nice because it means thatpushFile works whether you & # x27; re running locally, or on a cloud provider.

Let & # x27; s direct a aspect at a complete act example. In this example, we automate the built-in Google Photos app. First of all, we set up our craved capabilities to just use a built-in app:

DesiredCapabilities capability = new DesiredCapabilities (); capabilities.setCapability (`` platformName '', `` Android ''); capabilities.setCapability (`` deviceName '', `` Android Emulator ''); capabilities.setCapability (`` automationName '', `` UiAutomator2 ''); capabilities.setCapability (`` appPackage '', `` com.google.android.apps.photos ''); capabilities.setCapability (`` appActivity '', `` .home.HomeActivity ''); // Open the app. AndroidDriver driver = new AndroidDriver < > (new URL (`` http: //localhost:4723/wd/hub ''), capabilities);

Once the app is exposed, we have to sail through some UI boilerplate and other things Google require us to do to use their cloud. Of trend we are robots and not interested in their cloud! I & # x27; ve put this app state setup into its own method, along with setting up some locator constants, and logic that withdraw any existing pictures to create our verification easier subsequently on:

private electrostatic By backupSwitch = By.id (`` com.google.android.apps.photos: id/auto_backup_switch ''); private inactive By touchOutside = By.id (`` com.google.android.apps.photos: id/touch_outside ''); individual motionless By keepOff = By.xpath (`` // * [@ text='KEEP OFF '] ''); private static By exposure = By.xpath (`` //android.view.ViewGroup [contains (@ content-desc, 'Photo taken ')] ''); private inactive By trash = By.id (`` com.google.android.apps.photos: id/trash ''); individual static By moveToTrash = By.xpath (`` // * [@ text='MOVE TO TRASH '] ''); public void setupAppState (AndroidDriver driver) {// navigate through the google junk to get to the app WebDriverWait wait = new WebDriverWait (driver, 10); WebDriverWait shortWait = new WebDriverWait (driver, 3); wait.until (ExpectedConditions.presenceOfElementLocated (backupSwitch)) .click (); wait.until (ExpectedConditions.presenceOfElementLocated (touchOutside)) .click (); wait.until (ExpectedConditions.presenceOfElementLocated (keepOff)) .click (); // delete any live icon using an unnumbered loop break when we ca n't find any // more pictures try {while (true) {shortWait.until (ExpectedConditions.presenceOfElementLocated (photo)) .click (); shortWait.until (ExpectedConditions.presenceOfElementLocated (trash)) .click (); shortWait.until (ExpectedConditions.presenceOfElementLocated (moveToTrash)) .click ();}} catch (TimeoutException ignore) {}}

Finally we can get to the meat of our test, which relies upon the appropriate device media itinerary constant:

setupAppState (driver); // set up the file we desire to advertise to the phone 's library File assetDir = new File (classpathRoot, `` .. /assets ''); File img = new File (assetDir.getCanonicalPath (), `` cloudgrey.png ''); // actually push the file driver.pushFile (ANDROID_PHOTO_PATH + `` / '' + img.getName (), img); // waiting for the system to notice the new photo, and use the WebDriverWait to verify // that the new photo is there WebDriverWait wait = new WebDriverWait (driver, 10); ExpectedCondition condition = ExpectedConditions.numberOfElementsToBe (photo,1); wait.until (status);

As you can see, the literal bit we care some is as mere as callingpushFile. For the sake of this test, we are just verifying that our picture be at the end. In a real-world scenario, we & # x27; d then run our app functionality on the icon, and retrieve it from the device to perform some local confirmation on it.

Bringing it all together, the entire test class looks like the following:

import io.appium.java_client.android.AndroidDriver; import java.io.File; import java.io.IOException; import java.net.URL; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.TimeoutException; import org.openqa.selenium.remote.DesiredCapabilities; signification org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; // Note that to run correctly, this tryout must be run against a edition of Appium which includes // the appium-android-driver bundle at version 1.38 or high, since it contain relevant bugfixes public family Edition002_Android_Photos {private static String ANDROID_PHOTO_PATH = `` /mnt/sdcard/Pictures ''; private static By backupSwitch = By.id (`` com.google.android.apps.photos: id/auto_backup_switch ''); private static By touchOutside = By.id (`` com.google.android.apps.photos: id/touch_outside ''); private static By keepOff = By.xpath (`` // * [@ text='KEEP OFF '] ''); private static By photo = By.xpath (`` //android.view.ViewGroup [contains (@ content-desc, 'Photo taken ')] ''); private static By trash = By.id (`` com.google.android.apps.photos: id/trash ''); private static By moveToTrash = By.xpath (`` // * [@ text='MOVE TO TRASH '] ''); @ Test public void testSeedPhotoPicker () throws IOException {DesiredCapabilities capabilities = new DesiredCapabilities (); File classpathRoot = new File (System.getProperty (`` user.dir '')); capabilities.setCapability (`` platformName '', `` Android ''); capabilities.setCapability (`` deviceName '', `` Android Emulator ''); capabilities.setCapability (`` automationName '', `` UiAutomator2 ''); capabilities.setCapability (`` appPackage '', `` com.google.android.apps.photos ''); capabilities.setCapability (`` appActivity '', `` .home.HomeActivity ''); // Open the app. AndroidDriver driver = new AndroidDriver < > (new URL (`` http: //localhost:4723/wd/hub ''), capabilities); try {// there 's some screens we need to navigate through and ensure there are no existing photos setupAppState (driver); // set up the file we want to push to the telephone 's library File assetDir = new File (classpathRoot, `` .. /assets ''); File img = new File (assetDir.getCanonicalPath (), `` cloudgrey.png ''); // really push the file driver.pushFile (ANDROID_PHOTO_PATH + `` / '' + img.getName (), img); // wait for the system to acknowledge the new photo, and use the WebDriverWait to control // that the new photo is thither WebDriverWait wait = new WebDriverWait (driver, 10); ExpectedCondition condition = ExpectedConditions.numberOfElementsToBe (photo,1); wait.until (precondition);} finally {driver.quit ();}} public void setupAppState (AndroidDriver driver) {// navigate through the google junk to get to the app WebDriverWait wait = new WebDriverWait (driver, 10); WebDriverWait shortWait = new WebDriverWait (driver, 3); wait.until (ExpectedConditions.presenceOfElementLocated (backupSwitch)) .click (); wait.until (ExpectedConditions.presenceOfElementLocated (touchOutside)) .click (); wait.until (ExpectedConditions.presenceOfElementLocated (keepOff)) .click (); // delete any survive pictures using an myriad grommet broken when we ca n't find any // more pictures try {while (true) {shortWait.until (ExpectedConditions.presenceOfElementLocated (photo)) .click (); shortWait.until (ExpectedConditions.presenceOfElementLocated (trash)) .click (); shortWait.until (ExpectedConditions.presenceOfElementLocated (moveToTrash)) .click ();}} catch (TimeoutException ignore) {}}}

As always, you can check out the code in the context of all its dependencieson GitHub!

Author & # x27; s Profile

Jonathan Lipps

LinkedIn
Author & # x27; s Profile

Piali Mazumdar

Lead, Content Marketing, HeadSpin Inc.

Piali is a dynamic and results-driven Content Marketing Specialist with 8+ years of experience in crafting pursue narratives and marketing collateral across various manufacture. She excels in collaborating with cross-functional teams to evolve innovative content scheme and deliver compelling, veritable, and impactful message that vibrate with target audiences and enhances brand authenticity.

LinkedIn

Seeding an Android Device with Test Photos

4 Parts

regression intelligence blog
-

Regression Intelligence practical guide for advanced users (Part 3)

Coming Soon
Regression Intelligence practical guide for advanced users
-

Regression Intelligence practical guide for advanced users (Part 4)

Coming Soon

Discover how HeadSpin can empower your business with superior testing capabilities

Our Platform enables you to:
accelerate time-to-market
Accelerate time-to-market, win a competitive edge
faster development cycles
Boost developer/QA productiveness with faster development cycles
automated buil-over-build regression testing
Automate build-over-build fixation testing for consistent results
gain better visibility into functional & performance issues
Gain best visibility into functional and performance issues
reduce mean time
Reduce mean time to identify/resolve during test, QA, and production
evaluate audio, video & qoe
Evaluate audio, video, and content quality of experience (QoE) effortlessly
The trusted choice for global enterprise
Adobe
Hargreaves Lansdown
Truecaller
Crazylabs
Nedbank
Numeracle
Veryon
Close

Discover how HeadSpin can empower your business with superior testing capabilities

Our Platform enable you to:
accelerate time-to-market
Accelerate time-to-market, gaining a competitive edge
faster development cycles
Boost developer/QA productivity with faster development rhythm
automated buil-over-build regression testing
Automate build-over-build regression quiz for consistent outcome
gain better visibility into functional & performance issues
Gain best profile into functional and performance issues
reduce mean time
Reduce mean time to identify/resolve during test, QA, and production
evaluate audio, video & qoe
Evaluate audio, video, and content character of experience (QoE) effortlessly
The trusted choice for global enterprises
Close

Discover how HeadSpin can empower your business with superior testing capabilities

Our Platform enables you to:
accelerate time-to-market
Accelerate time-to-market, profit a free-enterprise edge
faster development cycles
Boost developer/QA productiveness with quicker evolution cycles
automated buil-over-build regression testing
Automate build-over-build regression essay for reproducible consequence
gain better visibility into functional & performance issues
Gain better profile into functional and performance issues
reduce mean time
Reduce mean time to identify/resolve during examination, QA, and production
evaluate audio, video & qoe
Evaluate audio, video, and content quality of experience (QoE) effortlessly
The trusted choice for spheric initiative
Close

Connet Now

Wipro LogoVMLYR Logo
Close
Book a Meeting
Products
footer down arrow
Solutions
footer down arrow
Industries
footer down arrow
Features
footer down arrow
Support
footer down arrow
Resource Center
footer down arrow
Why Choose HeadSpin?
footer down arrow
Copyright © 2026 HeadSpin, Inc. All Rights Reserved.

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free