Appium is an automation testing framework that allows you to write tests using the Selenium syntax that are for use in testing native, mobile web, and hybrid apps on iOS and Android devices. Run your Appium tests on Sauce Labs to benefit from speed, parallelization, clear test result history, failure analysis, issue tracking, and more.
- Don't have Appium tests but want to try? The Appium Demo Repo includes a sample project structure, working configuration specifications, and sample Java tests so you can get up and running in less than 10 minutes using the instructions on this page!
- Already have Appium tests to run? Take advantage of the Sauce Labs library of real devices, emulators and simulators, and OS/browser combinations to maximize your digital confidence on every version of every device.
What You'll Need
The following list of prerequisites are specific to running tests written in Java, per this demonstration. For information about other supported languages, refer to the demo projects in the Sauce Labs Training Repo.
- A Sauce Labs account (if you don't have one, start a free trial)
- Your Sauce Labs Username and Access Key
- The Sauce Labs Appium Demo Project
- A GitHub account
- The Swag Labs iOS Real Device Sample App
- Local installation of JDK, Maven, and an IDE such as IntelliJ. For instructions on installing each of these, see the Java Testing Dependencies training module.
Step 1: Clone the Sample Project
The Appium Quickstart for Java demo repo contains all the project files necessary to execute a test against a mobile app or a web app accessed through a mobile browser. Clone the project in your local environment to get started.
git clone https://github.com/saucelabs-training/quickstart-appium-java.git
Step 2: Link your Sauce Labs Account
SAUCE_ACCESS_KEY as environment variables to avoid having to enter them with each command and to protect them from exposure in your tests.
- Check to see whether your credentials are already set using the following command:Check Environment Variables
- If nothing is returned, use the following command to set your credentials:
export SAUCE_USERNAME="your Sauce username"
export SAUCE_ACCESS_KEY="your Sauce access key"
Step 3: Upload the Sample App
- Download the iOS Real Device Swag Labs App.
- Upload it to your Sauce Labs account, either through the Sauce Labs UI or by calling the API.
- Sauce Labs UI: From Sauce Labs Home --> LIVE--> Mobile App, select Upload App and browse to find the
iOS.RealDevice.SauceLabs.Mobile.Sample.app.2.7.1.ipafile you just downloaded.
- API: Use the Upload File to App Storage API request to upload the sample app to your account.
curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" --location \
--request POST 'https://api.us-west-1.saucelabs.com/v1/storage/upload' \
--form 'payload=@"/Users/lindsaywalker/Git/Example_Tests/iOS.RealDevice.SauceLabs.Mobile.Sample.app.2.7.1.ipa"' \
Step 4: Run the Tests
You must have JDK and Maven installed to run this sample test, and you must have set their paths in your
.bash_profile, for example:
## Maven Variables
If you are using an IDE, such as IntelliJ, open the
quickstart-appium-java project you cloned in step 2, then right-click the
src/test/java/tests/RDC/AppiumIosRdcAppTest and choose
Alternatively, you can run the following command in your terminal:
mvn clean test
Once your tests complete, you should be able to see the results in your Sauce Labs account under AUTOMATED --> Test Results --> Real Devices.