The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing

Insights

External Resources

More Info


Page tree
Skip to end of metadata
Go to start of metadata

The Sauce Labs real device cloud provides you with the ability to run either manual or automated tests across Android and iOS devices, in either a private or public cloud. Some of the features that are specific to our real device cloud include:

  • Manual testing on real devices
  • Private and public real device clouds
  • Support for Appium, Robotium, Espresso, and XCUITest frameworks
  • Support on hundreds of device-OS combinations
  • IPSec VPN secure connections to private clouds
  • Devices cleaning process between sessions to ensure maximum privacy
  • Carrier Network Connectivity (devices with SIM cards)

See the following sections for more information: 

What You'll Need

  • IMPORTANT: "Real Devices on Sauce" is currently available only to a small set of customers. If you are not already working with your Customer Success Manager on this program, you'll need to focus your attention on the "Legacy Test Object" content in each section that follows. 
  • Before you can upload your application and leverage real devices, you must fulfill the project support and requirements. Please review the Automated Mobile Application Testing Admin Guide for further details.

Uploading and Accessing your Application on Real Devices

Please select your preferred method for uploading your application in order to view the instructions:

  1. Log in to Sauce Labs and select LIVE from the options in the left-hand navigation.
  2. Select Mobile-App.
  3. You will see a list of previously uploaded apps.
  4. To the right of the page, select App Upload to upload a new application (Note: Live Testing on Real Devices only at the moment):

There may be situations where you want to install an application from a downloadable remote location (AWS S3 bucket, a GitHub repository, etc.). The application is completely removed from the real device after the test completes, providing an added layer of security for your application. Please review the following guidelines below before uploading your application:

Please review the following guidelines below before uploading your application:

  1. Make sure your application meets the prerequisite requirements for Android and iOS Mobile Application Testing.
  2. Upload your application to the hosting location.
  3. Ensure Sauce Labs has READ access to the app URL.
  4. In your Appium test script, enter the URL for the application as the "app" desired capability. Below is an example Java snippet:

    desiredCapabilities.setCapability("app", "https://drive.google.com/uc?export=download&id=1balA7M1p4cM-JgGh6aKbuGiPE4bPStDK");

Each Session is a "Fresh" Install

You will not be able to access information about different versions of your application because each session includes a "fresh" installation of your application. 

For Automated Appium Testing Only

You can only install remote applications for automated Appium testing. Espresso and Robotium automated tests are not supported. Live Testing is also not supported.

Here is an example of how to upload an application to the US West Data Center:

Mac OSX / Linux Example
$ curl -F "payload=@/Users/$SAUCE_USERNAME/Downloads/$FILE_NAME.ipa" -F "name=$FILE_NAME.ipa" -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY"  'https://api.us-west-1.saucelabs.com/v1/storage/upload'

For more examples and more detailed information on how to use the Storage API, visit the Application Storage page.

Running Your Test on Real Devices

Please select your Automated Mobile Application Testing use case:

Below are some examples of how to configure Appium tests for Real Devices.  For real device testing you'll need to grab the project API key and app ID. Please visit the Appium Capabilities for Real Device Testing page for required/optional capabilities and more advanced test configuration options. Also visit the sample test frameworks repository in GitHub for more detailed language-specific examples.

Using Regular Expressions for deviceName

The examples below use regular expressions for setting the deviceName, because a matching device must be present in your account in order for the test to run.

For example:

  • "iPhone.*""iPhone .*" will allocate any iPhone. "
  • .*nexus.*" will allocate any device with the word "nexus" in its display name.
  • "iPhone [67]" or "iPhone [6-7]" will allocate either "iPhone 7" or "iPhone 6" device.
  • "iPhone [67]S" or "iPhone [6-7]S" will allocate either "iPhone 7S" or "iPhone 6S" device. "iPhone 7.*" will allocate "iPhone 7" or "iPhone 7S", or any device that starts with the display name "iPhone 7"

Regular expressions are case insensitive, for example, "iphone .*S" and "IPHONe .*s" are the same.

Using Real Devices on Sauce Labs (app.saucelabs.com)

Below are examples of an iPhone project using iOS version 12.2.

DesiredCapabilities caps = DesiredCapabilities();
	caps.setCapability("username", "SAUCE_USERNAME");
	caps.setCapability("accessKey", "SAUCE_ACCESS_KEY");
	caps.setCapability("deviceName","iPhone .*");
	caps.setCapability("deviceOrientation", "portrait");
	caps.setCapability("platformVersion","12.2");
	caps.setCapability("platformName", "iOS");
	caps.setCapability("browserName", "");
	caps.setCapability("app", "sauce-storage:<upload_filename>");
caps = {}
caps['username'] = "SAUCE_USERNAME"
caps['accessKey'] = "SAUCE_ACCESS_KEY"
caps['browserName'] = ""
caps['deviceName'] = "iPhone .*"
caps['deviceOrientation'] = "portrait"
caps['platformVersion'] = "12.2"
caps['platformName'] = "iOS"
caps['app'] = "sauce-storage:<upload_filename>"
caps = {};
caps['username'] = 'SAUCE_USERNAME';
caps['accessKey'] = 'SAUCE_ACCESS_KEY';
caps['browserName'] = '';
caps['deviceName'] = 'iPhone .*';
caps['deviceOrientation'] = 'portrait';
caps['platformVersion'] = '12.2';
caps['platformName'] = 'iOS';
caps['app'] = 'sauce-storage:<upload_filename>';
caps = Selenium::WebDriver::Remote::Capabilities()
caps['username'] = 'SAUCE_USERNAME'
caps['accessKey'] = 'SAUCE_ACCESS_KEY'
caps['deviceName'] = 'iPhone .*'
caps['deviceOrientation'] = 'portrait'
caps['platformVersion'] = '12.2'
caps['platformName'] = 'iOS'
caps['browserName'] = ''
caps['app'] = 'sauce-storage:<upload_filename>'
DesiredCapabilities caps = new DesiredCapabilities();
	caps.SetCapability("username", "SAUCE_USERNAME");
	caps.SetCapability("accessKey", "SAUCE_ACCESS_KEY");
	caps.SetCapability("deviceName", "iPhone .*");
	caps.SetCapability("deviceOrientation", "portrait");
	caps.SetCapability("platformVersion", "12.2");
	caps.SetCapability("platformName", "iOS");
	caps.SetCapability("browserName", "");
	caps.SetCapability("app", "sauce-storage:<upload_filename>");

Below are examples of an Samsung Galaxy project using Android version 8.1.

DesiredCapabilities caps = DesiredCapabilities();
	caps.setCapability("username", "SAUCE_USERNAME");
	caps.setCapability("accessKey", "SAUCE_ACCESS_KEY");
	caps.setCapability("deviceName","Samsung.*Galaxy.*");
	caps.setCapability("deviceOrientation", "portrait");
	caps.setCapability("browserName", "");
	caps.setCapability("platformVersion","8.1");
	caps.setCapability("platformName","Android");
	caps.setCapability("app", "sauce-storage:<upload_filename>");
caps = {}
caps['username'] = "SAUCE_USERNAME"
caps['accessKey'] = "SAUCE_ACCESS_KEY"
caps['deviceName'] = "Samsung.*Galaxy.*"
caps['deviceOrientation'] = "portrait"
caps['platformVersion'] = "8.1"
caps['platformName'] = "Android"
caps['app'] = "sauce-storage:<upload_filename>"
caps = {};
caps['username'] = 'SAUCE_USERNAME';
caps['accessKey'] = 'SAUCE_ACCESS_KEY';
caps['deviceName'] = 'Samsung.*Galaxy.*';
caps['deviceOrientation'] = 'portrait';
caps['browserName'] = '';
caps['platformVersion'] = '8.1';
caps['platformName'] = 'Android';
caps['app'] = 'sauce-storage:<upload_filename>';
caps = Selenium::WebDriver::Remote::Capabilities()
caps['username'] = 'SAUCE_USERNAME'
caps['accessKey'] = 'SAUCE_ACCESS_KEY'
caps['deviceName'] = 'Samsung.*Galaxy.*'
caps['deviceOrientation'] = 'portrait'
caps['browserName'] = ''
caps['platformVersion'] = '8.1'
caps['platformName'] = 'Android'
caps['app'] = 'sauce-storage:<upload_filename>'
DesiredCapabilities caps = new DesiredCapabilities();
	caps.SetCapability("username", "SAUCE_USERNAME");
	caps.SetCapability("accessKey", "SAUCE_ACCESS_KEY");
	caps.SetCapability("deviceName", "Samsung.*Galaxy.*");
	caps.SetCapability("deviceOrientation", "portrait");
	caps.SetCapability("browserName", "");
	caps.SetCapability("platformVersion", "8.1");
	caps.SetCapability("platformName", "Android");
	caps.SetCapability("app", "sauce-storage:<upload_filename>");

Using the Legacy Platform (app.testobject.com)

Below are examples of an iPhone project using iOS version 12.2

DesiredCapabilities caps = DesiredCapabilities();
	caps.setCapability("testobject_api_key", "project_api_key");
	caps.setCapability("testobject_app_id", "1");
	caps.setCapability("deviceName","iPhone .*");
	caps.setCapability("deviceOrientation", "portrait");
	caps.setCapability("platformVersion","12.2");
	caps.setCapability("platformName", "iOS");
	caps.setCapability("browserName", "");
caps['browserName'] = ""
caps['testobject_api_key'] = "project_api_key"
caps['testobject_app_id'] = "1"
caps['deviceName'] = "iPhone .*"
caps['deviceOrientation'] = "portrait"
caps['platformVersion'] = "12.2"
caps['platformName'] = "iOS"
caps['browserName'] = '';
caps['testobject_api_key'] = "project_api_key";
caps['testobject_app_id'] = "1";
caps['deviceName'] = 'iPhone .*';
caps['deviceOrientation'] = 'portrait';
caps['platformVersion'] = '12.2';
caps['platformName'] = 'iOS';
caps = Selenium::WebDriver::Remote::Capabilities()
caps['testobject_api_key'] = 'project_api_key'
caps['testobject_app_id'] = '1'
caps['deviceName'] = 'iPhone .*'
caps['deviceOrientation'] = 'portrait'
caps['platformVersion'] = '12.2'
caps['platformName'] = 'iOS'
caps['browserName'] = ''
DesiredCapabilities caps = new DesiredCapabilities();
	caps.SetCapability("deviceName", "iPhone .*");
	caps.SetCapability("testobject_api_key", "project_api_key");
	caps.SetCapability("testobject_app_id", "1");
	caps.SetCapability("deviceOrientation", "portrait");
	caps.SetCapability("platformVersion", "12.2");
	caps.SetCapability("platformName", "iOS");
	caps.SetCapability("browserName", "");

Below are examples of an Samsung Galaxy project using Android version 8.1

DesiredCapabilities caps = DesiredCapabilities();
	caps.setCapability("testobject_api_key", "project_api_key");
	caps.setCapability("testobject_app_id", "1");
	caps.setCapability("deviceName","Samsung.*Galaxy.*");
	caps.setCapability("deviceOrientation", "portrait");
	caps.setCapability("browserName", "");
	caps.setCapability("platformVersion","8.1");
	caps.setCapability("platformName","Android");
caps = {}
caps['testobject_api_key'] = "project_api_key"
caps['testobject_app_id'] = "1"
caps['deviceName'] = "Samsung.*Galaxy.*"
caps['deviceOrientation'] = "portrait"
caps['platformVersion'] = "8.1"
caps['platformName'] = "Android"
caps = {};
caps['testobject_api_key'] = 'project_api_key';
caps['testobject_app_id'] = '1';
caps['deviceName'] = 'Samsung.*Galaxy.*';
caps['deviceOrientation'] = 'portrait';
caps['browserName'] = '';
caps['platformVersion'] = '8.1';
caps['platformName'] = 'Android';
caps = Selenium::WebDriver::Remote::Capabilities()
caps['testobject_api_key'] = 'project_api_key'
caps['testobject_app_id'] = '1'
caps['deviceName'] = 'Samsung.*Galaxy.*'
caps['deviceOrientation'] = 'portrait'
caps['browserName'] = ''
caps['platformVersion'] = '8.1'
caps['platformName'] = 'Android'
DesiredCapabilities caps = new DesiredCapabilities();
	caps.SetCapability("testobject_api_key", "project_api_key");
	caps.SetCapability("testobject_app_id", "1");
	caps.SetCapability("deviceName", "Samsung.*Galaxy.*");
	caps.SetCapability("deviceOrientation", "portrait");
	caps.SetCapability("browserName", "");
	caps.SetCapability("platformVersion", "8.1");
	caps.SetCapability("platformName", "Android");

Further Information on Configuring Appium Tests for Real Devices


Using Native Test Frameworks on Sauce Labs requires the Sauce Runner. Please visit the following pages for further information, example scripts, and demos using the Sauce Runner with native frameworks.

Best Practices and Reporting Test Results

Now that you've been able to get a test running on Sauce, there are a few other modifications you can make to your tests. These example scripts show how to:

You can find more information under Best Practices for Running Tests and Setting Test Status to Pass or Fail.

Additional Topics