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

Learn how to upload your application to emulators and simulators using Sauce Application Storage or installing from a remote location.

Below are the various ways you can upload your application for automated "emusim" (emulators and simulators) tests:

Uploading to Sauce Application Storage

Below are some examples on how to upload your application using the Storage API /upload method. Supported application file types include *.APK, *IPA, or *.ZIP (.ZIP must include a valid iOS application bundle) files of up to 4 GB.  In addition to the application itself, you can upload test assets (e.g., e.g., *.js, *.py, *.tar, *.zip, *.sh, *.bat) for use in your automated tests, such as pre-run executables. For more details about the Storage API, please visit Application Storage.

Uploading with cURL

If you're using cURL for the upload, you must include the @ before your file path, e.g. payload=@path/to/your_file_name

Mac OSX / Linux Android Application Example
$ curl -F 'payload=@/Users/<user-name>/Downloads/<file_name>.apk' -F name=<file_name>.apk -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY"  'https://api.us-west-1.saucelabs.com/v1/storage/upload'
Example Response (JSON)
{
   "item":{
      "id":"379c301a-199c-4b40-ad45-4a95e5f30a3a",
      "owner":{
         "id":"286c0fbb0cb644c4a012d505b8a0a1ac",
         "org_id":"c064890612424e34a12fca98ce4f32c6"
      },
      "name":"Android.SauceLabs.Mobile.Sample.app.2.3.0.apk",
      "upload_timestamp":1593450387,
      "etag":"0cf189b1c4c17a56656ada5e2d75cd51",
      "kind":"android",
      "group_id":2807,
      "metadata":{
         "identifier":"com.swaglabsmobileapp",
         "name":"Swag Labs Mobile App",
         "version":"2.3.0",
         "icon":"<long-serial-number>",
         "version_code":13,
         "min_sdk":16,
         "target_sdk":28
      },
      "access":{
         "team_ids":[
            "a15e40997f2b44ee9615d9803cb4b439"
         ],
         "org_ids":[

         ]
      }
   }
}
Windows Android Application Example
> curl -F 'payload=@\Users\<user-name>\Downloads\<file_name>.apk' -F name=<file_name>.apk -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%"  'https://api.us-west-1.saucelabs.com/v1/storage/upload'
Example Response (JSON)
{
   "item":{
      "id":"379c301a-199c-4b40-ad45-4a95e5f30a3a",
      "owner":{
         "id":"286c0fbb0cb644c4a012d505b8a0a1ac",
         "org_id":"c064890612424e34a12fca98ce4f32c6"
      },
      "name":"Android.SauceLabs.Mobile.Sample.app.2.3.0.apk",
      "upload_timestamp":1593450387,
      "etag":"0cf189b1c4c17a56656ada5e2d75cd51",
      "kind":"android",
      "group_id":2807,
      "metadata":{
         "identifier":"com.swaglabsmobileapp",
         "name":"Swag Labs Mobile App",
         "version":"2.3.0",
         "icon":"<long-serial-number>",
         "version_code":13,
         "min_sdk":16,
         "target_sdk":28
      },
      "access":{
         "team_ids":[
            "a15e40997f2b44ee9615d9803cb4b439"
         ],
         "org_ids":[

         ]
      }
   }
}

Then you need to reference a unique identifier (id) with the "app" capability in order to use the package file in your automated tests ("app":"<uuid>"). For more information visit the following section in the Application Storage page: Using Application Storage with Automated Test Builds.

Uploading to a Remote Location

There may be situations where you want to install an application from a downloadable remote location (AWS S3 bucket, a GitHub repository, etc.).

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 test script, enter the URL for the application as the "app" desired capability. Below are some example snippets:

    caps.setCapability("app", "https://github.com/saucelabs/sample-app-mobile/releases/download/2.2.1/iOS.Simulator.SauceLabs.Mobile.Sample.app.2.1.1.zip);
    caps.SetCapability("app", "https://github.com/saucelabs/sample-app-mobile/releases/download/2.2.1/iOS.Simulator.SauceLabs.Mobile.Sample.app.2.1.1.zip");
    app: 'https://github.com/saucelabs/sample-app-mobile/releases/download/2.2.1/iOS.Simulator.SauceLabs.Mobile.Sample.app.2.1.1.zip',
    'app':  'https://github.com/saucelabs/sample-app-mobile/releases/download/2.2.1/iOS.Simulator.SauceLabs.Mobile.Sample.app.2.1.1.zip',
    app: 'https://github.com/saucelabs/sample-app-mobile/releases/download/2.2.1/iOS.Simulator.SauceLabs.Mobile.Sample.app.2.1.1.zip'

Uploading to Legacy Sauce Storage

Sauce Storage is a private temporary storage space. Files uploaded will expire seven days after upload, and be removed.  If it has been over seven days since you uploaded your application to Sauce Storage, you will need to upload it again. You can upload the application you want to test to Sauce Storage using our REST API, and then access it for testing by specifying sauce-storage:myapp for the app capability in your test script.  You upload apps using  the  upload_file  method of the Sauce Labs REST API

You can use any REST client; cURL is a convenient command-line option.

US-WEST Data Center

MacOS/Linux Example
$ curl -u $SAUCE_USERNAME:$SAUCE_ACCESS_KEY -X POST -H "Content-Type: application/octet-stream" \
"https://saucelabs.com/rest/v1/storage/$SAUCE_USERNAME/$APP_NAME?overwrite=true" --data-binary @path/to/your_file_name

US-EAST Data Center

MacOS/Linux Example
$ curl -u $SAUCE_USERNAME:$SAUCE_ACCESS_KEY -X POST -H "Content-Type: application/octet-stream" \
"https://us-east-1.saucelabs.com/rest/v1/storage/$SAUCE_USERNAME/$APP_NAME?overwrite=true" --data-binary @path/to/your_file_name

EU-CENTRAL Data Center

MacOS/Linux Example
$ curl -u $SAUCE_USERNAME:$SAUCE_ACCESS_KEY -X POST -H "Content-Type: application/octet-stream" \
"https://eu-central-1.saucelabs.com/rest/v1/storage/$SAUCE_USERNAME/$APP_NAME?overwrite=true" --data-binary @path/to/your_file_name

US-WEST Data Center

Windows Example
> curl -u %SAUCE_USERNAME%:%SAUCE_ACCESS_KEY% -X POST -H "Content-Type: application/octet-stream" \
"https://saucelabs.com/rest/v1/storage/%SAUCE_USERNAME%/%APP_NAME%?overwrite=true" --data-binary @path\to\your_file_name

US-EAST Data Center

Windows Example
> curl -u %SAUCE_USERNAME%:%SAUCE_ACCESS_KEY% -X POST -H "Content-Type: application/octet-stream" \
"https://us-east-1.saucelabs.com/rest/v1/storage/%SAUCE_USERNAME%/%APP_NAME%?overwrite=true" --data-binary @path\to\your_file_name

EU-CENTRAL Data Center

Windows Example
> curl -u %SAUCE_USERNAME%:%SAUCE_ACCESS_KEY% -X POST -H "Content-Type: application/octet-stream" \
"https://eu-central-1.saucelabs.com/rest/v1/storage/%SAUCE_USERNAME%/%APP_NAME%?overwrite=true" --data-binary @path\to\your_file_name