- A Sauce Labs Account.
- The native or hybrid mobile app you want to test. If you don't have one on hand and want to test this functionality, try our Sauce Labs demo mobile app.
- Ensure that your system fulfills the project support and requirements prior to uploading your apps or leveraging device emulators and simulators. Review the Automated Mobile App Testing Admin Guide for further details.
To begin, you'll need to upload your app to a publicly available source. Accepted file types are .zip iOS package files for simulators and .apk Android package files for emulators. There are three ways you can upload your app for automated testing:
- Sauce App Storage
- Install from a Remote Location
- Legacy (TestObject) Sauce Storage
For step-by-step instructions on uploading your app, see Application Storage.
- After you've uploaded your app, open a new test script. Add your Sauce Labs credentials (
accessKey). We also recommend exporting your Sauce Labs credentials to environment variables.macOS/Linux Exampleexport SAUCE_USERNAME=********export SAUCE_ACCESS_KEY=*******
The next step is to configure your app using Appium capabilities compatible with Sauce Labs emulators and simulators. Test configuration will depend on your testing use case.
Authentication of the Sauce Labs platform, as well as advanced Test Configuration Options, requires the use of the W3C WebDriver-compliant
sauce:optionscapability. Here are some tips for configuring Appium for your tests:
appiumVersionin your test script. While not required, if you omit this, your test will run with our default Appium version.
We recommend specifying one of the newer Appium versions, which will provide a more extended API and fixes to known bugs.
- Check the Appium version for your test:
- Log in to Sauce Labs.
- Find and select the test that you ran using Appium to view the Test Details page.
- Click the Metadata tab.
- Look for the Logs row and select Appium Log. The first line should indicate the Appium version. For example:2014-05-05T17:45:07.541Z - info: Welcome to Appium v1.9.0.
- If you're testing a native mobile app, set the value for
browserNameas an empty string, for example:caps.setCapability("browserName", "");
- If the app you want to test has been uploaded to a location other than Sauce Storage, you'll need to specify this location for
app, and make sure that this location is accessible to Sauce Labs browsers. For example:caps.setCapability("app","sauce-storage:mapp.zip");
automationName for Android Apps#
- If you're testing a native mobile app against Android versions 4.0 - 4.1, or a hybrid mobile against Android versions 4.0 - 4.2, you need to set the capability
These Android versions are only supported via Appium’s bundled version of Selendroid, which utilizes Instrumentation. Later versions of Android are supported via Appium’s own UIAutomator library.
- Before you running your test(s), you'll need to configure your Appium capabilities to communicate with the Sauce Labs virtual device cloud. Described below are required and optional Appium test capabilities and example scripts.
For Example Purposes Only
The code in these scripts is provided on an "AS-IS” basis without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement. Your tests and testing environments may require you to modify these scripts. Issues regarding these scripts should be submitted through GitHub. These scripts are not maintained by Sauce Labs Support.
Below are examples of an iPhone 8 project using iOS version 12.2:
Below are examples of an Samsung Galaxy S9 Plus project using Android version 8.1:
iPhone Native App
iPad Native App
iPhone Hybrid App,
Android Native App, Android version 4.3.
Android Hybrid App, Android version 4.1.
These Appium scripts for iOS and Android mobile app tests on emulators and simulators can help streamline your testing process. Below are links to the Sauce Labs Training on GitHub repository, where you'll find demo scripts for a variety of use cases to get you started with automated Appium testing:
Once you've been able to get a test running on Sauce, check out our best practices and available modifications you can make to your tests:
- Best Practices for Running Tests
- Implement timeouts to control text execution times
- Annotating Tests with the Sauce Labs REST API
- Setting Test Status to Pass or Fail
- Using Build IDs and tags to differentiate and identify test runs
- Create your own test script examples using our Platform Configurator
- Browse our full suite of test configuration options and advanced configurations.