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

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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

Unable to render {include} The included page could not be found.

PAGE DEPRECATED: updated content available here.

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:

    Example Java Snippet
    caps.setCapability("app", "https://github.com/saucelabs/sample-app-mobile/releases/download/2.3.0/Android.SauceLabs.Mobile.Sample.app.2.3.0.apk?raw=true");

Installing your Application on Private Devices

In some cases you may need to upload / install your application to a private device and also prevent the device from broad internet access while under test. The steps to achieve this are:

  • Upload your application to an internal git repository, or private hosting solution with the necessary permissions (e.g. Amazon S3 with a strict bucket policy).
  • Ensure the hosted app URL is available to the machine running the automated test.
  • Ensure that you've enabled the "Require Sauce Connect/VPN" setting in your organization's security settings.


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.

PAGE DEPRECATED: updated content available here.

Below are some examples of how to use the Sauce Labs REST API to upload your mobile application to Sauce Storage. If you do not have an app, consider using the Sauce Labs Swag Labs sample app for validating your account functionality as well as your tests. 

Choosing a REST API

The APIs and authorization credentials you use depend on what you run Appium tests with:

  • RDC on Sauce/Sauce Labs - Please use the Sauce Labs Storage REST API (app.saucelabs.com)
  • Legacy Real Devices/Test Object - Please use the Legacy Real Device Cloud REST API (app.testobject.com)

For details related to authorization credentials, see Data Center Endpoints

Please select your Sauce Labs Testing Platform:

RDC on Sauce API

Currently only the Sauce Storage endpoint is supported for automated testing on real devices. Please use the endpoint below to upload your application to the Sauce Labs Storage:

US Data Center

Mac OSX / Linux Example
$ curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" -X POST -w "%{http_code}\n" \
-H "Content-Type: application/octet-stream" \
"https://saucelabs.com/rest/v1/storage/$SAUCE_USERNAME/Android.SauceLabs.Mobile.Sample.app.x.x.x.apk?overwrite=true" \
--data-binary @/path/to/Android.SauceLabs.Mobile.Sample.app.x.x.x.apk
Windows Example
> curl -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY% -X POST -w "%{http_code}\n" \
-H "Content-Type: application/octet-stream" \
"https://saucelabs.com/rest/v1/storage/%SAUCE_USERNAME%/Android.SauceLabs.Mobile.Sample.app.x.x.x.apk?overwrite=true" \
--data-binary @\path\to\Android.SauceLabs.Mobile.Sample.app.x.x.x.apk

EU Data Center

Mac OSX / Linux Example
$ curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" -X POST -w "%{http_code}\n" \
-H "Content-Type: application/octet-stream" \
"https://eu-central-1.saucelabs.com/rest/v1/storage/$SAUCE_USERNAME/Android.SauceLabs.Mobile.Sample.app.x.x.x.apk?overwrite=true" \
--data-binary @/path/to/Android.SauceLabs.Mobile.Sample.app.x.x.x.apk
Windows Example
> curl -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%" -X POST -w "%{http_code}\n" \
-H "Content-Type: application/octet-stream" \
"https://eu-central-1.saucelabs.com/rest/v1/storage/%SAUCE_USERNAME%/Android.SauceLabs.Mobile.Sample.app.x.x.x.apk?overwrite=true" \
--data-binary @\path\to\Android.SauceLabs.Mobile.Sample.app.x.x.x.apk

Legacy Test Object API

US Data Center

Mac OSX / Linux Example
$ curl -u "$TEST_OBJECT_USERNAME:$TEST_OBJECT_API_KEY" -X POST \
"https://app.testobject.com:443/api/storage/upload" -H \
"Content-Type: application/octet-stream" --data-binary @/path/to/Android.SauceLabs.Mobile.Sample.app.x.x.x.apk
Windows Example
> curl -u "%TEST_OBJECT_USERNAME%:%TEST_OBJECT_API_KEY%" -X POST \
"https://app.testobject.com:443/api/storage/upload" -H \
"Content-Type: application/octet-stream" --data-binary @\path\to\Android.SauceLabs.Mobile.Sample.app.x.x.x.apk



EU Data Center

Mac OSX / Linux Example
$ curl -u "$TEST_OBJECT_USERNAME:$TEST_OBJECT_API_KEY" -X POST \
"https://app.testobject.com:443/api/storage/upload" -H \
"Content-Type: application/octet-stream" --data-binary @/path/to/Android.SauceLabs.Mobile.Sample.app.x.x.x.apk
Windows Example
> curl -u "%TEST_OBJECT_USERNAME%:%TEST_OBJECT_API_KEY%" -X POST \
"https://app.testobject.com:443/api/storage/upload" -H \
"Content-Type: application/octet-stream" --data-binary @\path\to\Android.SauceLabs.Mobile.Sample.app.x.x.x.apk







In order to upload your apps from Microsoft App Center to a Sauce Labs data center you must create a post-build script in Microsoft App Center. Please note, if you're looking for the legacy solution please visit the Legacy Platform App Center Integration page.

What You'll Need

Creating the post-build Script

  1. Once you've linked your project source code to your app center project, create a script called appcenter-post-build.sh and add it to your project source code repository.
  2. If you're testing a cross-platform application (e.g. a react-native), add the following environment variables APP_NAME and BUILD_NAME.

    If you're building a single project (iOS or Android) ignore steps 2-4 and skip to step 5.

    #!/usr/bin/env bash
    APP_NAME="your.app.name"
    # You can find this name in the build logs of a previous project
    # for now we create an empty variable and change it based on the
    # project that is using this script
    BUILD_NAME="your.build.name"
  3. Set the correct app name based on the application platform.

    if [[ "$APPCENTER_XCODE_PROJECT" ]]; then
        APP_NAME="iOS.SauceLabs.Mobile.Sample.app.ipa"
        BUILD_NAME="SwagLabsMobileApp.ipa"
    else
        APP_NAME="Android.SauceLabs.Mobile.Sample.app.apk"
        BUILD_NAME="app-release.apk"
    fi
  4. You can optionally set a console message to appear in your App Center logs.

    echo "**************** PUBLISH APP TO SAUCELABS WITH THIS DATA ******************"
    echo "APP NAME                => $APP_NAME"
    echo "BUILD NAME              => $BUILD_NAME"
    echo "OUTPUT DIRECTORY        => $APPCENTER_OUTPUT_DIRECTORY"
    echo "PAYLOAD                 => $APPCENTER_OUTPUT_DIRECTORY/$BUILD_NAME"
  5. Now you can add the following command to push to the relevant data center that contains your target real device.

    Push to US Data Center
    curl \
      -F "payload=@$APPCENTER_OUTPUT_DIRECTORY/$BUILD_NAME" \
      -F name=$APP_NAME \
      -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY"  'https://api.us-west-1.saucelabs.com/v1/storage/upload'
    Push to EU Data Center
    curl \
      -F "payload=@$APPCENTER_OUTPUT_DIRECTORY/$BUILD_NAME" \
      -F name=$APP_NAME \
      -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY"  'https://api.eu-central-1.saucelabs.com/v1/storage/upload'

    If you need to retrieve a specific build, or information regarding the build that ran during this operation, you can use the Application Storage API.

  6. Here's the full script in the Sauce Labs sample mobile app repo:

    Not found

    Could not find the given branch refs/remotes/origin/master

  • No labels