Help Index

Sahi Website

Does Testuff have an automation API?

Yep! It allows your automation to update test results in Testuff. Automation can also be used to automatically export your data.

How does it work?

Via HTTP POST over SSL. Your Testuff login details are used for identification. Each test has a unique ID. Test results are POSTed to the relevant API URL and include – as parameters – the test ID, lab name, and test result. Following the request, Testuff updates the test result accordingly. Read more about the automation URL on the automation page.

Sahi integration how-to

  1. Have a look at the example in sahi/userdata/scripts/testuff.sah.
    SAHI has added a callback onScriptEnd to Sahi, which will always be called at the end of a script (even on errors). From onScriptEnd, they call postTestuff() with the correct parameters, and the data gets posted.
  2. Add postTestuff to your code, and call it from inside onScriptEnd().

Sample: Sahi

_setValue(_textbox("user"), "test");
_setValue(_password("password"), "secret");
_setValue(_textbox("q"), "2");
_setValue(_textbox("q[1]"), "1");
_setValue(_textbox("q[2]"), "1");
_assertEqual("1150", _textbox("total").value);

// onScriptEnd is a callback called by Sahi when script finishes
function onScriptEnd(){
postTestuff("atest_id", _scriptStatus());

function encode(source) {
var enc = new Packages.sun.misc.BASE64Encoder();
var src = new java.lang.String(source);
return (enc.encode(src.getBytes()));

// Please call the postTestuff method with all its parameter and check.
// postTestuff("763993f3929542f50a3a0dd2b259876a","passed");

function postTestuff(test_id, status, steps_failed, steps_passed, steps_maybe,
lab_name, version, run_configuration, comment, branch_name) {
var login = "testuff_login_email";
var password = "password";
var authKey = "Testuff API";

// Replace the X with your server number, as found under Settings-->Company details
var url = "";

var data = {
"test_id" : test_id,
"status" : status,
"steps_failed" : steps_failed,
"steps_passed" : steps_passed,
"steps_maybe" : steps_maybe,
"lab_name" : lab_name,
"version" : version,
"run_configuration" : run_configuration,
"branch_name" : branch_name,
"comment" : comment

var $request = new RESTRequest();
$request.setCredentials(login, pass, authKey);
$request.setHeader("Content-Type", "application/json");
$request.setHeader("Accept", "application/xml");
$request.$body = _sahi.toJSON(data);
var $response = $request.submit("post"); // changed get to post
var $responseCode = $response.getResponseCode();
_log("Response code:" + $responseCode);
var $body = $response.getBodyAsString(); // returns the response as XML
// _log($body);

Help Index