Skip to content

Instantly share code, notes, and snippets.

@KL-7
Forked from tarun3kumar/updatesauceLabsresults.java
Created January 3, 2012 19:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save KL-7/1556552 to your computer and use it in GitHub Desktop.
Save KL-7/1556552 to your computer and use it in GitHub Desktop.
Update SauceLabs Results

List:

  • foo
  • bar

This is an H1

This is an H2

@AfterMethod(alwaysRun = true)
public void shutDownDriver(ITestResult result) throws IOException {
}@AfterMethod(alwaysRun = true)
public void shutDownDriver(ITestResult result) throws IOException {
    
    // Update SauceLabs result
    if(testbed.equals("saucelab")) {
        String jobID = ((RemoteWebDriver)driver).getSessionId().toString();
        SauceREST client = new SauceREST("username", "key");
        Map<String, Object>sauceJob = new HashMap<String, Object>();
        sauceJob.put("name", "Test method: "+result.getMethod().getMethodName());
        if(result.isSuccess()) {
            client.jobPassed(jobID);
        } else {
            client.jobFailed(jobID);
        }
        client.updateJobInfo(jobID, sauceJob);            
    }
    driver.manage().deleteAllCookies();
    driver.quit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment