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

The methods described in this section allows you obtain information about and manage completed test jobs.

Some of the methods take an inline parameter of <JOB_ID>. You can obtain a job's ID in any of the following ways:

  • Each job result returned in GET /rest/v1/USERNAME/jobs includes an "Id" value that corresponds to the JOB ID.
  • The WebDriver object's “sessionId” attribute is the Sauce Labs JOB ID.
  • In the Sauce Labs app, the Metadata tab of a test's details provides the 'Id" that corresponds to the JOB ID.


Get Jobs

Retrieve the list of recent jobs belonging to a specific user.

GET /rest/v1/<USERNAME>/jobs


Parameters

limit

optional

positive integer, default 100, max 500

 Specifies the number of jobs to return

skip

optional

positive integer, default 0

Skips the specified number of jobs

from

optional

timestamp

 Get jobs since the specified time

to

optional

timestamp

 Get jobs until the specified time

format

optional 

string, one of json or csv

default json

 Get job info in the specified format

Example getting the last 100 job IDs, skipping 20 most recent jobs
curl -u USERNAME:ACCESS_KEY 'https://saucelabs.com/rest/v1/USERNAME/jobs?limit=100&skip=20'
 Response Data

The get jobs call returns an array of jobs meeting the criteria set in the call. Each job returned includes the following attributes:

AttribueFormatDescription
status



stringThe current status of the job, such as completed.
base_configobjectThe set of platform configurations on which the test was executed, such as sauce:options settings, the browser and OS versions, etc.
command_countsobjectA breakdown of the total number of commands executed in the job and the number of errors. 

deletion_time

StringThe Unix timestamp representing the time at which the job was deleted.
urlStringThe URL address of the web driver log file.
org_idStringThe unique identification for the organization of which the job owner is a member.
creation_timeIntegerThe Unix timestamp representing the time at which the job was instantiated.
idStringThe unique identification of the job. Also known as the JOB_ID or the Webdriver SessionId.
team_idStringThe unique identification of the team to which the job owner is assigned.
performance_enabledBooleanWhether the test options set performance to true.
assigned_tunnel_idStringThe unique identification of the tunnel used for the test.
containerBooleanWhether the job is a parent test.
group_idStringThe unique identification for the job category
publicStringSpecifies who is able to view the job, based on the Visibility setting.
breakpointedBooleanWhether this test's execution was halted using the Sauce Breakpoint feature.

Get Builds

See build details for a given username and access key.

GET /rest/v1/<USERNAME>/builds
Example getting build details for user.
 curl -u USERNAME:ACCESS_KEY 'https://saucelabs.com/rest/v1/USERNAME/builds/'

Get Job Details

Retrieve job details for the specified JOB_ID.

GET /rest/v1/<USERNAME>/jobs/<JOB_ID>
Example getting details for a specific job.
curl -u USERNAME:ACCESS_KEY 'https://saucelabs.com/rest/v1/USERNAME/jobs/JOB_ID'

Update Job

Edit an existing job

PUT /rest/v1/<USERNAME>/jobs/<JOB_ID>

NOTE: Because of the complex syntax required for updating job information via cURL, consider updating job information using the methods described in Test Configuration and Annotation.

Parameters

name

optional

string

 If specified change the job name

tags

optional

string, JSON array

If present set tags for job

public

optional

string or boolean

Set job visibility 

Example values:

  • public
  • public restricted
  • share or true
  • team or false 
  • private

passed

optional

boolean

Set whether the job passed or not on the user end

build

optional

string

The build name for this test.

Example value: main-160546445-13928244

custom-data

optional 

JSON object

Extra key-value pairs with any info that a user would like to add to the job.

Max data allowed is 64KB

curl -X PUT -u USERNAME:ACCESS_KEY \
-H "Content-Type: application/json" \
-d '{
"tags": ["testing-rest-api"],
"name": "REST API Test",
"custom-data": {"source": "Testing REST API"}
}' \ 
'https://saucelabs.com/rest/v1/USERNAME/jobs/JOB_ID'

 Delete Job

Removes the job from the system with all the linked assets

If you're using classic team management:

DELETE /rest/v1/<USERNAME>/jobs/<JOB_ID>
curl -X DELETE -u USERNAME:ACCESS_KEY 'https://saucelabs.com/rest/v1/USERNAME/jobs/JOB_ID' 


If you're using extended team management:

DELETE /rest/v1.1/jobs/<JOB_ID>
curl -X DELETE -u USERNAME:ACCESS_KEY 'https://saucelabs.com/rest/v1.1/jobs/JOB_ID' 

Note: only job owner, team admin or organization admin can remove the job. See more about user roles.

Delete all user Jobs

This endpoint can be used only if you're using extended team management.

DELETE /rest/v1.1/<USERNAME>/jobs
curl -X DELETE -u USERNAME:ACCESS_KEY 'https://saucelabs.com/rest/v1.1/USERNAME/jobs' 

Note: only jobs owner, team admin or organization admin can remove jobs. See more about user roles.

Stop Job

Terminates a running job

PUT /rest/v1/<USERNAME>/jobs/<JOB_ID>/stop
curl -X PUT -u USERNAME:ACCESS_KEY 'https://saucelabs.com/rest/v1/USERNAME/jobs/JOB_ID/stop' 

Get Job Asset Names

Get details about the static assets collected for a specific job

Response Fields

Each of these fields will be set to null if the specific asset isn't captured for a job

sauce-log: [string] Name of the Sauce log recorded for a job

selenium-log: [string] Name of the selenium Server log file produced by a job

video: [string] Name of the video file name recorded for a job

screenshots: [array of strings] List of screenshot names captured by a job

GET /rest/v1/<USERNAME>/jobs/<JOB_ID>/assets
curl -u USERNAME:ACCESS_KEY 'https://saucelabs.com/rest/v1/USERNAME/jobs/JOB_ID/assets' 

Get Job Asset Files

Download job assets. After a job completes, all assets created during the job are available via this API. These include the screencast recording, logs, and screenshots taken on crucial steps.

The job assets will be deleted from the test page after 30 days. Thus, after 30 days all your test commands, logs, screenshots and the screencast recording will be gone. This is the reason why we strongly recommend to download your job assets if this is an information that you must keep in your records.

GET /rest/v1/<USERNAME>/jobs/<JOB_ID>/assets/<FILE_NAME> 

Parameters

file_name

required

Accepted values

selenium-server.log

video.mp4

XXXXscreenshot.png (where XXXX is a number between 0000 and 9999)

final_screenshot.png

curl -u USERNAME:ACCESS_KEY -O 'https://saucelabs.com/rest/v1/USERNAME/jobs/JOB_ID/assets/final_screenshot.png' 

 Delete Job Assets

Delete all the assets captured during a test run. This includes the screencast recording, logs, and all screenshots.

DELETE /rest/v1/<USERNAME>/jobs/<JOB_ID>/assets
curl -X DELETE -u USERNAME:ACCESS_KEY 'https://saucelabs.com/rest/v1/USERNAME/jobs/JOB_ID/assets'