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

No Real Device Cloud Support

The following information in this page will not work currently for RDC on Sauce Labs.

When it comes to sharing results of your Sauce Labs tests, you can generate sharable links that restrict the audience by requiring a login or authentication (auth) token. These links will allow the recipient to view the Test Details page for that test, but the test results will not appear in their dashboard. 

Another option is change the visibility of your tests (i.e., public, private, internal) directly on your Test Details page > Visibility and simply sharing the page URL with recipients. For more info, see Sharing the Results of Sauce Labs Tests.

What You'll Need

When generating a shareable link, you'll need to know your specific Data Center. All examples on this page the US-West-1 Data Center endpoint, If you're using another Data Center, such as EU-Central-1, your link should be altered accordingly (e.g., See Data Center Endpoints for more info.

Linking to Tests that Require a Login to View

You can create links to your tests that'll only work if you're logged in with the account that ran the test or if that account is one of your sub-accounts. 

In Selenium, when a client requests a new browser session, the server returns a session ID, which is used to identify that session throughout the test. The session ID is stored as a member variable of the instantiated Selenium object and named sessionId or session_id, depending on the client library. Sauce uses that session ID as the test ID for accessing test results.

To directly access a specific job, you will first need to note the session ID locally, usually by writing it to a log file. You can then use it to create a URL with the following format and replace YOUR_TEST_ID with the session ID. For example:

As previously mentioned, all examples on this page use the US-West-1 Data Center endpoint. If you're using another Data Center, such as EU-Central-1, your link should be altered accordingly (e.g., See Data Center Endpoints for more info.

Linking to Tests that Don't Require a Login to View

You can also create sharable links that are based on authentication (auth) tokens, meaning the recipient won't have to login and use your credentials.

Auth tokens are generated on a per-test basis and grant viewers access using an hmac-based algorithm. You can also find hmac implementations for different programming languages.

The digest algorithm to use is MD5. The message and key used to generate the token should be the following:

  • Key: sauceUsername:sauceAccessKey
  • Message: test-id

Here's an example in Python for generating the token in the Python interpreter for a test with id: 5f9fef27854ca50a3c132ce331cb6034.

>>> import hmac
>>> from hashlib import md5
>>>"SAUCE_USERNAME:SAUCE_ACCESS_KEY", "5f9fef27854ca50a3c132ce331cb6034", md5).hexdigest()

Once the auth token has been obtained, you can use it to build a link in this format:

Support for Secondary Accounts

If you want to authenticate as another user, just prefix the auth token with your username, followed by a colon.

For example: 

Setting Your Test Links to Expire

You can extend the links generated with authentication tokens to make them work temporarily for a specific date or specific hour, based on the parameters that you set.

During the hmac generation, set the key like this: SAUCE_USERNAME:SAUCE_ACCESS_KEY:YOUR_DATE_RANGE.

The date range can take two formats: YYYY-MM-DD-HH and YYYY-MM-DD. These should be set in UTC time and will only work during the date or hour you set.