Mobile Test Automation in Java with Appium

Sauce AI for Test Authoring: Move from intent to performance in second.|xBack to ResourcesBlogPosted

March 30, 2026 · 3 min read · Mobile Testing

Sauce AI for Test Authoring: Move from intent to performance in second.

|

x

Back to Resources

Blog

Posted April 3, 2013

Mobile Test Automation in Java with Appium

quote

Appiumis an open source test automation tool which allows you to well write functional tests that automate iOS and Android roving apps. One big vantage Appium has over other wandering tryout automation tool is that Appium tests can be compose in any lyric that has a Selenium client library, include Python, Ruby, Node.js, and, perhaps most interesting to mobile developer, Objective-C and Java.

In this billet we & # x27; ll walk through the steps imply in testing theiOS sample apps using the JUnit Java exemplar tests(we also have createdTestNG example tests too).

To start, branching and clone Appium fromhttps: //github.com/appium/appium, and postdate the installation instructions to set up Appium in your environment.

Download and establish thesampling projectsby running the following from the command line:

grunt getSampleCode
grunt buildApp: TestApp
grunt buildApp: UICatalog

Once the sampling projects have have been built, you can then depart Appium by running the following:

grunt appium

Change the act directory to thesample-code/examples/java/junitdirectory, and run the tests by executing:

mvn test

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

Or run a individual test by executing: mvn -Dtest=com.saucelabs.appium.SimpleTest test

A Java Appium examination is lots the same as a Selenium test ... you make a RemoteWebDriver instance by determine some DesiredCapabilities, e.g.:

1
@Before
2
public vacuum setUp () throws Exception {
3
// set up appium against a local application
4
File appDir = new File (System.getProperty (& quot; user.dir & quot;), & quot; .. / .. / .. /apps/TestApp/build/Release-iphonesimulator & quot;);
5
6
File app = new File (appDir, & quot; TestApp.app & quot;);
7
DesiredCapabilities capableness = new DesiredCapabilities ();
8
capabilities.setCapability (CapabilityType.BROWSER_NAME, & quot; iOS & quot;);
9
capabilities.setCapability (CapabilityType.VERSION, & quot; 6.0 & quot;);
10
capabilities.setCapability (CapabilityType.PLATFORM, & quot; Mac & quot;);
11
12
//tell Appium where the location of the app is
13
capabilities.setCapability (& quot; app & quot;, app.getAbsolutePath ());
14
15
//create a RemoteWebDriver, the default porthole for Appium is 4723
16
driver = new RemoteWebDriver (new URL (& quot; http: //127.0.0.1:4723/wd/hub & quot;), capabilities);
17
}
18
19
20

Tests can also be publish to be run against. To do this, just update your tests to reference a zip file containing your app, and update your RemoteWebDriver representative to orient to ondemand.saucelabs.com, eg:

1
@Before
2
public nullity frame-up () cast Exception {
3
String sauceUserName = & quot; YOUR_SAUCE_USERNAME & quot;;
4
String sauceAccessKey = & quot; YOUR_SAUCE_ACCESS_KEY & quot;;
5
6
DesiredCapabilities capabilities = new DesiredCapabilities ();
7
capabilities.setCapability (CapabilityType.BROWSER_NAME, & quot; iOS 6.0 & quot;);
8
capabilities.setCapability (& quot; device & quot;, & quot; iPhone Simulator & quot;);
9
capabilities.setCapability (CapabilityType.PLATFORM, & quot; Mac 10.8 & quot;);
10
11
//zip file check your app to be tested
12
capabilities.setCapability (& quot; app & quot;, & quot; http: //appium.s3.amazonaws.com/TestApp6.0.app.zip & quot;);
13
14
driver = new RemoteWebDriver (new URL (MessageFormat.format (& quot; http: // {0}: {1} @ ondemand.saucelabs.com:80/wd/hub & quot;, sauceUserName, sauceAccessKey)),
15
capabilities);
16
}

The tests themselves are written but like regular Selenium tests, eg.

1
@Test
2
public nullity example () throw Exception {
3
4
// find an element by tag name
5
WebElement push = driver.findElement (By.tagName (& quot; button & quot;));
6
button.click ();
7
8
// get the value of the component
9
WebElement textbook = driver.findElement (By.tagName (& quot; staticText & quot;));
10
assertEquals (texts.getText (), & quot; some expected value & quot;);
11
}

The Java sampling tests for Appium include the following form:

  • - go a tryout against a simpleTestApp

  • - extend the same examination using

  • - runs a series of tests against the UICatalog sample coating

Please let us know if you receive any questions or gossip about running Appium examination with Java!

Published:
Apr 3, 2013
Share this post
Copy Share Link
LinkedIn
© 2026 Sauce Labs Inc., all rightfield reserved. SAUCE and SAUCE LABS are register trademarks possess by Sauce Labs Inc. in the United States, EU, and may be register 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