Building links to jobs
Login required links to jobs
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. We use that session ID as the job id for accessing test results on our website.
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 <jobid> with the session ID.
Notice that links to jobs in this format will only work if you are logged in with the account that ran the job or if that account is a subaccount of yours. For generating public links, read the section below, no-login links to jobs.
No-login links to jobs
The links generated in login required links to jobs can be made in a way that doesn't require anonymous viewers to login and use your credentials. This mechanism is based in authentication tokens.
Auth tokens are generated on per job basis and give the receiver access using an hmac-based algorithm. You can also find hmac implementations for the different programming languages.
The digest algorithm to use is MD5. The message and key used to generate the token should be the following:
Here's an example in Python for generating the token for a job with id: 5f9fef27854ca50a3c132ce331cb6034
>>> import hmac >>> from hashlib import md5 >>> hmac.new("example_user:123456-asdf-8dcf81f1fc71", "5f9fef27854ca50a3c132ce331cb6034", md5).hexdigest() '3fca4184e106622adf2d33d8023271c1'
Once the auth token has been obtained, it can be used to build a link in the following format:
For our example job, the link would end up being:
Notice: the link won't work as this job doesn't really exist.
Temporary links to jobs
There's a way to extend the links generated in no-login links to jobs to make them work only temporarily.
The authentication token can be generated in a way that provides 1 hour or
1 day of access to the job by using the following information for the hmac
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 chosen and the following.
Downloading job assets
You can download every asset created after your test runs on Sauce through our REST API. These include the video recording, Selenium log, and screenshots taken on crucial steps. After a standard job execution, the following files are created:
- XXXXscreenshot.png (where XXXX is a number between 0000 and 9999)
To pull them, make a request matching the following pattern:
Sauce uses HTTP Basic Authentication. Each request needs to include an authorization HTTP header with your username and access key.
Here's an example using curl to download selenium-server.log:
$ curl -u jhuggins:763a23a1-91e1-4f6b-be79-oiu722855hvh https://saucelabs.com/rest/v1/jhuggins/jobs/2z234fd4c4006b1e73faf3fa3cdadc75/assets/selenium-server.log
Embedding Results in HTML Pages
Embedding full job pages
We offer a simple way to embed job pages in CI test results or other test reports. Using the format below, add the HTML to any page you need to embed job results on, replacing <job_id> with the ID of the job you want:
Note: this will only work for browsers logged in using your account, and authentication tokens can be used to make this work for anonymous viewers. Check out no-login links to jobs for directions on generating these tokens.
Embedding the video player
In addition to full job results, we offer a simple way to embed videos as well. Using the format below, add the HTML to any page you need to embed job videos on, replacing <job_id> with the ID of the job you want:
Note: this will only work for browsers logged in using your account, and authentication tokens can be used to make this work for anonymous viewers. Check out no-login links to jobs for directions on generating these tokens. Here's how such a script might look:
For more advanced usage and integrations, you should read our REST API documentation.