saucerest-java

SauceREST Java codecov.io example workflow Maven Central


A Java client for Sauce Labs 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_WEST);

Parameters:

Name Type Details
username String (required) your sauce labs username
access-key String (required) your sauce labs accesskey
data_center String or DataCenter (required) one of US_WEST, US_EAST, EU_CENTRAL, APAC_SOUTHEAST

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](https://docs.saucelabs.com/dev/test-configuration-options/#TestConfigurationOptions-Disablevideorecording.

// 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();

SauceREST 2.x

With version 2.x of SauceREST we have made code-breaking changes to this wrapper. It has been updated to be more future-proof and to also support the newest APIs from Sauce Labs.

This is going to be continuous process which means we will release changes to SauceREST over time.

Storage

Get all files

Storage storage = new SauceREST(DataCenter.EU_CENTRAL).getStorage();
GetAppFiles getAppFiles = storage.getFiles();

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 for details.

Want a fast, setup dev environment? Open in Gitpod.

Hacktoberfest

Here for Hacktoberfest?. Check out Our Hacktoberfest Issues, or visit https://opensource.saucelabs.com/hacktoberfest/ to see all our Hacktoberfest projects!