You've might have come across the term "job ID", "test ID" or "session ID" in our documentation. These refer to the unique ID which each Sauce Labs job has. You can find it in the URL of a jobs page, and in the test summary pane.
This value is also used by any remote Selenium session as the session ID. When you use the selenium-webdriver or sauce gems to drive a job, every action you take until you call #quit is performed for the same session.
So once you have this session ID, you've got a unique reference to a job and all its resources. This means you can use it to:
Set job metadata like build-id, using our REST API
Download all screenshots, or the Selenium log, or the test video
Stop a job remotely
Drop links to failing test videos in Campfire
Get faster support from support@saucelabs.com
(By the way, the following examples are for Ruby, but all these tasks are possible with other languages... Check out the 'Download the Video' and 'Stop a job remotely' examples)
Previously, getting the session ID from a selenium-webdriver object was... well... If it was a baby, you'd tell the mother it had an "interesting" face and then immediately change the subject (here's the discussion why). So, you might encounter some examples like this:
## I... You... *{hurk}* job_id = @driver.send(:@bridge).session_id
job_id = @driver.instance_variable_get("@bridge").instance_variable_get("@session_id")
Well, none of that. Jari Bakken has added a sweet convenience method directly to the remote driver:
job_id = @driver.session_id
The session_id is just a string, so with a little bit of setting up, it becomes super easy to do all the stuff listed above.
job_id = @driver.session_id un = Sauce.get_config[:username] ac = Sauce.get_config[:access_key]
****Provide links to jobs
puts "Your job: https://www.saucelabs.com/tests/#{job\_id}"
**Set Metadata with Sauce_Whisk
**
job = SauceWhisk.job.new(:id => job_id) job.build = "1337" job.save
**Stop a job remotely
**
`curl -X PUT https://#{username}:#{access}@saucelabs.com/rest/v1/#{username}/jobs/#{job\_id}/stop -d ''`
**Download the video
**
video = `curl https://#{username}:#{access\_key@saucelabs.com/rest/v1/#{username/jobs/#{job\_id}/assets/video.flv -s`
Easy, huh?