Cross-Platform Android and iOS Automation Testing with Appium

Sauce AI for Test Authoring: Move from intent to execution in minutes.|xBack to ResourcesBlogPosted

May 16, 2026 · 3 min read · Mobile Testing

Sauce AI for Test Authoring: Move from intent to execution in minutes.

|

x

Back to Resources

Blog

Posted September 16, 2016

Cross-Platform Android and iOS Automation Testing with Appium

quote

Did you know that Appium permit you to indite a single examination script and execute it on both Android and iOS for automation examine? There is no need to duplicate a ton of code by creating two separate, most identical test scripts! Keep on reading to find out how.

How does writing a single script that runs on two different platforms employment?

The first tool you will need for this is Appium.

There are different Appium setups you can use, but PageObject is the ideal approach for this specific testing purpose. You can read more aboutPageObject setupin our documentation.

So let ’ s imagine you are using a PageObject-based setup to pen your trial scripts for your Android calculator app. At this point, you are plausibly referencing the bulk of the UI elements you are interact with, expend annotation, possibly like the ones shown below:

@ AndroidFindBy (id = & quot; net.ludeke.calculator: id/plus & quot;)
individual MobileElement buttonPlus;

@ AndroidFindBy (id = “ net.ludeke.calculator: id/equal ”)
private MobileElement buttonEquals;

For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.

Now let ’ s image that you have build a calculator coating for iOS as good and you need to cite these same elements on it. How do you do this?

Well it is in fact quite simple: you can only add another note on top of the existing ones, like so:

@ iOSFindBy (id = & quot; plus_sign & quot;)
@ AndroidFindBy (id = & quot; net.ludeke.calculator: id/plus & quot;)
private MobileElement buttonPlus;

@ iOSFindBy (id = “ equal_sign ”)
@ AndroidFindBy (id = “ net.ludeke.calculator: id/equal ”)
private MobileElement buttonEquals;

So what the code above does is: whenever an Android driver is being instantiated for your test, the @ AndroidFindBy notation will be used; when the iOS driver is being instantiated, the @ iOSFindBy annotation will be used.

There is too no need to stick to IDs: you can specify a different referencing strategy bet on the program and it will look like so:

@ iOSFindBy (approachability = & quot; plus & quot;)
@ AndroidFindBy (id = & quot; net.ludeke.calculator: id/plus & quot;)
private MobileElement buttonPlus;

So you can choose the referencing scheme you like most.

The big benefit in writing a single script for both Android and iOS automation testing, is that you are not duplicating as much codification. This imply: leisurely maintenance of your exam scripts and less headaches!

Published:
Sep 16, 2016
Share this post
Copy Share Link
LinkedIn
© 2026 Sauce Labs Inc., all rights reserved. SAUCE and SAUCE LABS are register trademarks owned by Sauce Labs Inc. in the United States, EU, and may be registered in other jurisdictions.
robot
quote

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