The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing

Analytics

External Resources

More Info


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

If you want to test a native or hybrid mobile application, it must be in a location that is  accessible over the Internet for the Sauce Labs virtual machines to connect to it. There are two options for where you can upload your app:

If you want to test a mobile application on a virtual device , it must be in a location that is accessible over the Internet for the Sauce Labs virtual machines to connect to it.

Uploading Mobile Apps

Sauce Storage

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. 

Uploading Other Test Assets to Sauce Storage

While uploading your mobile application to Sauce Storage or another accessible online location is a requirement for mobile application testing, you can also use Sauce Storage for other assets that you want to use in your tests, such as pre-run executables.

Sauce Storage is Private Temporary Storage

Sauce Storage is a private 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.

Upload Your App Using the REST API

iOS .app Applications Must be in a .zip File

If you create your iOS application as a .app directory with multiple files, you need to export it as a .zip file before uploading. If you have created your app as a .ipa file, you can upload that file directly without needing to zip it up.

You upload apps using  the  upload_file  method of the Sauce Labs REST API. You can use any REST client or cURL, as shown in these examples. 

Uploading with cURL

If you're using cURL for the upload, you must include the @ before path/to/your_file_name

OS X/Linux Example of Using cURL to Upload an App to Sauce Storage

curl -u <sauce_username>:<sauce_access_key> -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/<sauce_username>/<upload_filename>?overwrite=true --data-binary @<path/to/your_file_name>

Windows Example of Using cURL to Upload an App to Sauce Storage

curl -u <sauce_username>:<sauce_access_key> -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/<sauce_username>/<upload_filename>?overwrite=true --data-binary @/<path/to/your_file_name>

Parameters for the upload_file method

ParameterDescription
sauce_usernameYour Sauce Labs username
sauce_access_keyYour Sauce Labs access key
upload_filename

The name you want to use for the file under Sauce Storage, for example SuperApp.zip or myApp.apk.

This is the name you will refer to when you set the app, sauce-storage:myfilename capability in your test script, not the name of the file as it appears on your local system.
path/to/your_file_name

The path to where the file is saved on your local system, for example users/Tester/builds/super_app_tst_1228_build.zip


Uploading to Other Locations

  1. Make sure your application meets the Requirements for Android and iOS Mobile Application Testing.
  2. Upload your application to the hosting location.

iOS .app Applications Must be in a .zip File

If you create your iOS application as a .app directory with multiple files, you need to export it as a .zip file before uploading. If you have created your app as a .ipa file, you can upload that file directly without needing to zip it up. 

Accessing Mobile Apps in Your Tests

Sauce Storage

Access to the Sauce Storage location is limited to the users associated with you account. After seven days, any assets in Sauce Storage are deleted, so if you need to test your app again after seven days, you will need to upload it again. 

 After you've uploaded the file, you can set your test to reference the application at the Sauce Storage URL with the app capability, as shown in this example for Java.

DesiredCapabilities caps = DesiredCapabilities.iphone();
caps.setCapability("appiumVersion", "1.4.16");
caps.setCapability("deviceName","iPhone 6");
caps.setCapability("deviceOrientation", "portrait");
caps.setCapability("platformVersion","9.2");
caps.setCapability("platformName", "iOS");
caps.setCapability("browserName", "");
caps.setCapability("app","sauce-storage:myapp.zip");

Other Accessible Locations

Other accessible locations could include Dropbox, AWS, or any other file storage service. As with the Sauce Storage location, you need to specify the path to your application with the app capability:

DesiredCapabilities caps = DesiredCapabilities.android();
caps.setCapability("appiumVersion", "1.4.16");
caps.setCapability("deviceName","Android Emulator");
caps.setCapability("deviceType","phone");
caps.setCapability("deviceOrientation", "portrait");
caps.setCapability("browserName", "");
caps.setCapability("platformVersion","5.1");
caps.setCapability("platformName","Android");
caps.setCapability("app","http://mycorp.intranet/myapp.apk");