saucerest-java

SauceREST Java codecov.io Build Status ==============

A Java client for Sauce Labs’s REST API.

Using this client you can update Job info, including pass/fail status and other information supported. Only the Sauce Labs Virtual Device Cloud is supported. For Real Devices, please see the docs.

If a function you’re after isn’t supported, we suggest either shelling out and using the curl version, or sending a pull request! Contribution Details Here.

http://saucelabs.com/docs/sauce-ondemand#alternative-annotation-methods

Usage

Create an instance of the client

SauceREST sauce = new SauceREST("username", "access-key", "data_center");

OR

SauceREST sauce = new SauceREST("username", "access-key", Datacenter.US);

Paramaters:

Name Type Details
username String (required) your sauce labs username
access-key String (required) your sauce labs accesskey
data_center String (optional) one of US, US_EAST, EU (Default US)

Users generally only have access to their own jobs and resources. Parent accounts may have access to their children’s jobs. Check out the Sauce Labs documentation for more information.

Change a job’s metadata

Mark a job passed or failed:

sauce.jobPassed(job_id);
sauce.jobFailed(job_id);

Get all tunnels

String tunnels = sauce.getTunnels();

Download Assets

Assets are downloaded by providing a job ID and the location to save the asset to.

Filenames are set automatically to jobId_yyyyMMdd_HHmmSS_filename.ext, where yyyyMMdd_HHmmSS is the retrieval timestamp and ext is determined by the asset type.

Each of these methods comes in two flavours; the downloadX methods which ignore exceptions, and the downloadXOrThrow methods which throw:

The downloadX methods return a boolean indicating if the download was successful.

Selenium log

// Download the log; Ignore exceptions
sauce.downloadLog("job_id", "/var/tmp/");  // => true if the Log downloads correctly

// Download the log; Raise SauceException.NotAuthorized, FileNotFound, IOException
sauce.downloadLogOrThrow("job_id", "/var/tmp");

Extension: .log

HAR File

HAR files are only available for jobs using Extended Debugging.

// Download the HAR file; Ignore exceptions
sauce.downloadHAR("job_id", "/var/tmp/"); // => true if the HAR File downloads correctly

// Download the HAR file; Raise SauceException.NotAuthorized, FileNotFound, IOException
sauce.downloadHAROrThrow("job_id", "/var/tmp");

Extension: .har

Video

Video is only available for jobs which have not disabled video recording.

// Download the Log; Ignore exceptions
sauce.downloadVideo("job_id", "/var/tmp"); // => true if the Video downloads correctly

// Download the Log; Raise SauceException.NotAuthorized, FileNotFound, IOException
sauce.downloadVideoOrThrow("job_id", "/var/tmp");

Extension: .mp4

Get Information

About a particular job

sauce.getJobInfo("job_id");

About the last 20 jobs

sauce.getJobInfo();

About a requested number of jobs

sauce.getJobInfo(n);  #n is the number of jobs to retrieve, as an integer

About your tunnels

String tunnels = sauce.getTunnels();

Maven

<dependencies>
  <dependency>
    <groupId>com.saucelabs</groupId>
    <artifactId>saucerest</artifactId>
    <version>LATEST VERSION</version>
    <scope>test</scope>
  </dependency>
</dependencies>

For latest version please check the following link: https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.saucelabs%22%20AND%20a%3A%22saucerest%22.

Contributing

Check out our contribution guide Here.