Automating the Clipboard on iOS and Android

April 06, 2026 · 9 min read · Mobile Testing

HeadSpin Platform
Automated & amp; manual examination made leisurely through datum science insights.
Differentiating capabilities:
  • Wide end-to-end automation of QA process
  • Comparative analysis of app performance against peers
  • Uninterrupted monitoring of app execution habituate synthetic data for higher availability of apps
  • Easy-to-use developer friendly program
cloudtest go
Low-priced Real Device Testing for Emerging Teams
cloudtest go
Low-cost Real Device Testing for Digital Enterprises
cloudtest go
The Ultimate Solution for a Powerful Blend of Functional & amp; Performance Testing!
cyol
TEM
New
Centralized roving trial execution in cloud
cyol
Enhance Your Accessibility Testing With HeadSpin
cyol
Automate camera-based examination

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

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

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

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

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

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

retail

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

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

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

Automating Clipboard on iOS and AndroidAutomating Clipboard on iOS and Android

Automating the Clipboard on iOS and Android

Published on
May 9, 2018
Updated on
Published on
June 5, 2022
Updated on
 by 
 Jonathan LippsJonathan Lipps
Jonathan Lipps

Copying and pasting is one of those classic pairing, like peanut butter and jelly, or pizza and beer, or chips and guacamole. (Hmm, am I athirst?). For programmers, replicate and pasting is bad -- -we should refactor our code instead. For exploiter of nomadic apps, copying and pasting is a wonderful way to save time typing and remembering. For this reason, both iOS and Android platforms offer system-level clipboard capacity, which apps can hook into to incorporate into their own functionality.

Accelerate Appium test rhythm with the HeadSpin..

If you find yourself automating an app which has behavior tie to the clipboard, you might wonder how you can automatize this behavior. As a first walk, you might try to do it the way a user would: by finding or typing some text, so long-pressing, then selecting the & quot; copy & quot; or & quot; paste & quot; context buttons which appear. Unfortunately, these buttons are & quot; especial & quot; and don & # x27; t show up in the mechanization hierarchy, which means this technique won & # x27; t work reliably.

Check out:

Thankfully, Appium now exposes getter and setter command for the clipboard across both platforms. The specifics of the way the clipboard act, and what you can do with it, vary by platform (for example, determine image data is possible with the iOS clipboard). However, the basic flow of copying and pasting textbook act the same way across both platforms, and this is our topic for this article.

To showcase this type of automation, I & # x27; ve createdadaptation 1.4.0 of The App, which has a new & quot; Clipboard Demo & quot; vista:

Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.

Clipboard Demo

Basically, we can either tap the & quot; Refresh & quot; push and get the contents of the clipboard displayed on screen, or we can enter our own text into a text battleground and set that schoolbook as the text message of the clipboard. We & # x27; ll use this little demo aspect to understand Appium & # x27; s clipboard method. Our test steps will look like:

  1. Set the clipboard text to & quot; Hello World & quot;
  2. Tap the & quot; Refresh & quot; push
  3. Verify that the text displayed on the scene is & quot; Hello World & quot;
  4. Enter & quot; Hello World Again & quot; into the text field
  5. Tap the & quot; Set & quot; button
  6. Get the clipboard text using Appium
  7. Verify the clipboard text was & quot; Hello World Again & quot;

These test stairs prove that our app does exactly what it purports to do (which is confessedly pretty dim).

Also check out:

Eagle-eyed testers will receive noticed that the seven steps above really constitute two exam, one that proves our app aright displays the clipboard text and one that evidence it right sets it. Let & # x27; s lead measure 1-3 1st, and look at how we would write it up in an Appium script:

String text = `` Hello World ''; driver.setClipboardText (text); driver.findElement (refreshClipboardBtn) .click (); Assert.assertEquals (driver.findElement (clipboardText) .getText (), text);

(Here we assume we & # x27; ve got someBy locators all ready for us to use). The magic method isdriver.setClipboardText, which enables us to set the clipboard text to anything we want. We & # x27; re capable to use this technique to prove beyond a shadow of a doubt that when we hit the & quot; Refresh & quot; button the displayed schoolbook actually get from the clipboard.

Also read:

And of class, this method has a Gemini, which enables the second tryout (steps 4-7):

text = `` Hello World Again ''; driver.findElement (clipboardInput) .sendKeys (text); driver.findElement (setTextBtn) .click (); Assert.assertEquals (driver.getClipboardText (), text);

Here, all we & # x27; re doing is enter a unequaled string into the text field and hitting the & quot; Set Clipboard Text & quot; push. Then, we & # x27; re habituate Appium & # x27; sgetClipboardTextmethod to find the clipboard text from the gimmick, so we can verify it was actually set via the app. If the strings match, we & # x27; ve proved our app was capable to set the clipboard textbook successfully.

That & # x27; s all there is to it! This works in a fully cross-platform style, as our entire example will show, with tryout for each of iOS and Android that both phone out to the sameautomateClipboardmethod:

signification io.appium.java_client.AppiumDriver; import io.appium.java_client.MobileBy; signification io.appium.java_client.android.AndroidDriver; import io.appium.java_client.clipboard.HasClipboard; import io.appium.java_client.ios.IOSDriver; significance java.io.IOException; import java.net.URL; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; signification org.openqa.selenium.By; import org.openqa.selenium.remote.DesiredCapabilities; importation org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; @ RunWith (JUnit4.class) public class Edition016_Clipboard {individual String ANDROID_APP = `` https: //github.com/cloudgrey-io/the-app/releases/download/v1.4.0/TheApp-v1.4.0.apk ''; individual String IOS_APP = `` https: //github.com/cloudgrey-io/the-app/releases/download/v1.4.0/TheApp-v1.4.0.app.zip ''; private String AVD_NAME = `` emu27 ''; individual String APPIUM_SERVER = `` http: //localhost:4723/wd/hub ''; private By clipboardNav = MobileBy.AccessibilityId (`` Clipboard Demo ''); private By refreshClipboardBtn = MobileBy.AccessibilityId (`` refreshClipboardText ''); individual By clipboardInput = MobileBy.AccessibilityId (`` messageInput ''); private By setTextBtn = MobileBy.AccessibilityId (`` setClipboardText ''); @ Test world void testClipboard_Android () throws IOException {DesiredCapabilities capabilities = new DesiredCapabilities (); capabilities.setCapability (`` platformName '', `` Android ''); capabilities.setCapability (`` deviceName '', `` Android Emulator ''); capabilities.setCapability (`` automationName '', `` UiAutomator2 ''); capabilities.setCapability (`` avd '', AVD_NAME); capabilities.setCapability (`` app '', ANDROID_APP); AndroidDriver driver = new AndroidDriver (new URL (APPIUM_SERVER), capabilities); automateClipboard (driver);} @ Test public emptiness testClipboard_iOS () throws IOException {DesiredCapabilities capabilities = new DesiredCapabilities (); capabilities.setCapability (`` platformName '', `` iOS ''); capabilities.setCapability (`` platformVersion '', `` 11.3 ''); capabilities.setCapability (`` deviceName '', `` iPhone 7 ''); capabilities.setCapability (`` app '', IOS_APP); IOSDriver driver = new IOSDriver (new URL (APPIUM_SERVER), capabilities); automateClipboard (driver);} private void automateClipboard (AppiumDriver driver) {WebDriverWait wait = new WebDriverWait (driver, 5); try {wait.until (ExpectedConditions.presenceOfElementLocated (clipboardNav)) .click (); String text = `` Hello World ''; ((HasClipboard) driver) .setClipboardText (text); wait.until (ExpectedConditions.presenceOfElementLocated (refreshClipboardBtn)) .click (); By clipboardText = MobileBy.AccessibilityId (schoolbook); Assert.assertEquals (driver.findElement (clipboardText) .getText (), text); text = `` Hello World Again ''; driver.findElement (clipboardInput) .sendKeys (text); try {driver.hideKeyboard ();} catch (Exception ign) {} driver.findElement (setTextBtn) .click (); Assert.assertEquals (((HasClipboard) driver) .getClipboardText (), text);} finally {driver.quit ();}}}

In this model, we have two tests, one for iOS and one for Android, each of which is responsible solely for setting up its unique capabilities. Then, the heavy lifting is execute by theautomateClipboardmethod, which simply takes anAppiumDriverand works its trick. Because we don & # x27; t have an representative ofIOSDriver or AndroidDriverspecifically, we have to cast our driver example toHasClipboardin order to create sure we however have access to the clipboard methods (which properly belong only on the platform-specific drivers). And of course, in the full model, we use explicit waits to make sure we don & # x27; t run into any timing issues with element presence.

If you fancy a deeper look at the code, you can always visit its abodeon GitHub.

Author & # x27; s Profile

Jonathan Lipps

LinkedIn
Author & # x27; s Profile

Piali Mazumdar

Lead, Content Marketing, HeadSpin Inc.

Piali is a dynamical and results-driven Content Marketing Specialist with 8+ years of experience in crafting engage narratives and marketing collateral across diverse industries. She excels in collaborating with cross-functional teams to develop groundbreaking substance strategies and deliver compelling, authentic, and impactful content that resonates with mark audiences and enhances brand authenticity.

LinkedIn

Automating the Clipboard on iOS and Android

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 gift your occupation with superior testing capabilities

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

Discover how HeadSpin can empower your job with superior testing capabilities

Our Platform enables you to:
accelerate time-to-market
Accelerate time-to-market, gaining a free-enterprise edge
faster development cycles
Boost developer/QA productivity with faster ontogeny cycles
automated buil-over-build regression testing
Automate build-over-build fixation test for consistent termination
gain better visibility into functional & performance issues
Gain best visibility into functional and execution subject
reduce mean time
Reduce mean time to identify/resolve during test, QA, and product
evaluate audio, video & qoe
Evaluate audio, video, and contented lineament of experience (QoE) effortlessly
The trusted alternative for global go-ahead
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, gaining a competitory edge
faster development cycles
Boost developer/QA productivity with faster development cycle
automated buil-over-build regression testing
Automate build-over-build regression testing for consistent answer
gain better visibility into functional & performance issues
Gain better visibility into functional and performance issues
reduce mean time
Reduce mean clip to identify/resolve during test, QA, and production
evaluate audio, video & qoe
Evaluate sound, video, and content lineament of experience (QoE) effortlessly
The sure choice for global enterprises
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