The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing


External Resources

More Info

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

Visual Studio Team Services (VSTS) enables continuous delivery by speeding up the testing cycle while increasing the quality of mobile and desktop applications. With Sauce Plugin for VSTS users can easily pass Sauce Labs authentication credentials as a part of the VSTS build process, Launch & Stop Sauce Connect Proxy, and embed the report around the statuses of executed tests.

Team Server 2015 Version 2 Required

You must have Team Foundation Server 2015 Update 2 installed to use Sauce Labs with VSTS. Previous versions will not be able to install the new extension format.  

Installing Sauce

  1. Navigate to Visual Studio Marketplace and install (for Cloud instances) or download the plugin (for on-premises versions).

  2. Update your tests to set build in your capabilities as shown in the examples.

  3. Add Sauce Labs steps into your build pipeline

    Once the plugin is installed, you will be able to access the steps Manage Sauce Credentials and Stop Sauce Connect, as described in the relevant sections in this topic.

  4. Build as normal.

  5. Click Sauce Labs on the build result page to view a summary of tests that were executed on Sauce.

Examples for Setting Build Capabilities


 capabilities.SetCapability("build", Environment.GetEnvironmentVariable("SAUCE_BUILD_NAME"));


desiredCapabilities.setCapability("build", System.getEnv("SAUCE_BUILD_NAME"));

Setting Up the Sauce Labs "Manage Credentials" Task for Your Build

The Manage Credentials task is what allows you to authenticate with your Sauce Labs account via VSTS and start Sauce Connect. You need to configure the task to create a new service endpoint that will contain your Sauce Labs username and access key.

  1. In your VSTS dashboard, click Build & Release.
  2. Under Build Definition, choose an appropriate template for your project. 
  3. Click Edit, to edit build details (if it is an existing build) or New to create a new build
    1. Configure your Source Settings for the project.
      1. Users who don't have a working set of sets could refer to our sample repository 
    2. Click Create.
  4. Click Add Task
  5. Under Test, search for and add Sauce Labs - Manage Credentials.
  6. Next, click on the newly added step and under  Sauce Labs Credentials menu, click Manage.
  7. This will open the Services tab.
  8. Click New Service Endpoint
  9. Select New Sauce Labs Credentials
  10. For Connection Name, enter an appropriate name.
  11. For User name and API Token, enter your Sauce username and access key.
  12. Click OK.
  13. Go back to the build steps for your project, and make sure that under Control Options for the Manage Credentials task, the Enabled option is selected 

Using Sauce Connect

Sauce Connect is a tunneling application that established a secure connection between applications or sites under test in your local network or machine, and the virtual machines running browsers in the Sauce Labs testing cloud. It is not necessary to set up Sauce Connect to run tests with the Sauce Labs browser cloud, you only need to use it if the application or site under test is not publicly accessible over a network. Check out the topics under Sauce Connect Proxy for more information. 

If you want to use Sauce Connect with VSTS, you need to both Enable Sauce Connect in your Manage Credential task and add the Sauce Labs - Stop Sauce Connect task to your build. These will start up a Sauce Connect tunnel when your build begins, and then close the tunnel when it finishes.

  1. In your Manage Credentials task, click Enable Sauce Connect.
  2. Select whether the task should Always run and/or Continue on error.
  3. In your build definition, search for and add Sauce Labs - Stop Sauce Connect.
  4. Make sure that the Sauce Labs - Stop Sauce Connect task is enabled.
    We recommend that you set this task to Always run so there are no extra Sauce Connects tunnels stay running after your job ends.

Task Order is Important

If you use the Sauce Connect tasks in your build, you must have your build steps set up so that the Sauce Labs - Manage Credentials task executes first.