Page tree
Skip to end of metadata
Go to start of metadata

The SeeTest Reporter provides you with a Rest API that gives you direct access to the test data and statistics.

For documentation on Transaction View please follow : 

Concepts

  1. Key - Key and value construct a tag. Each test has a subset of available tags with various values that describe the test specifics. Example: {device.os : Android}.

  2. Project - Concept derived from the cloud. Each project has it's own resources (users, devices) and can be used to created separation of testing efforts.
  3. Test - Single test execution instance.


The role of the user performing the Rest Operation is specified by the 'Authorization' header.

For more information please visit How To Execute Rest API, for a detailed example.


Get test Transactions

Returns JSON representation of existing Test Transaction with received {id}.

If it does not exist a status 404 is returned.

  • This API is available for all user roles.

GET /reporter/api/transactions/{ids}

{id} - id of the transaction.

Response

Response Status: 200 OK

{
  "id"744,
  "name""Test Rail",
  "appName""com.apple.springboard",
  "appVersion""",
  "startTime"1584958844127,
  "deviceUid""00008020-00152DA11A68002E",
  "deviceName""iPhone xs b0227",
  "deviceModel""iPhone XS",
  "deviceOs""iOS",
  "deviceManufacturer""Apple",
  "deviceVersion""13.3",
  "deviceScreen""1125 x 2436",
  "deviceType""PHONE",
  "networkProfile""",
  "cpuAvg"211.10688234412152,
  "cpuMax"836.3230590820312,
  "memAvg"553.8927731721298,
  "memMax"622.5054931640625,
  "batteryAvg"374.1950969080771,
  "batteryMax"490.32733154296875,
  "totalUploadedBytes"0,
  "totalDownloadedBytes"0,
  "duration"31283,
  "speedIndex"-1,
  "videoStart"1584958844127,
  "videoEnd"1584958875410,
  "userName""admin",
  "testId"639,
  "date""2020-03-23",
  "projectId"1,
  "projectName""Default",
  "attachmentList": []
}

Delete test Transactions

Delete the test transactions identified by the received IDs. One or more ids can be provided, separated by a comma.

Example: /api/transactions/3,4,23


  • This API is available for cloudAdmin and projectAdmin only.

DELETE /reporter/api/transactions/{ids}

{id} - id of the transaction.

Comparison of transaction's measuresfilter


It generates a comparison of average transaction measures between the latest base key-value and older key values.

POST /reporter/api/transactions/compare?token=<accessKey>

Json parameter

Name

Type

Mandatory

Description

(warning)(warning)(warning)(warning)

Response

Response Status: 200 OK

{
  "id"56,
  "name""newTestViewsGroup",
  "byKey""date",
  "byKeyDesc"true,
  "groupByKey1""device.os",
  "groupByKey2""device.version",
  "filter": [],
  "keys": [
    "date",
    "app"
  ],
  "createdBy""admin"
}

See  Performance Pipeline for more details 

Download HAR file


  • This API is available for all user roles.

Downloads the HAR file attached to the transaction id received as the path parameter.

GET /reporter/api/transactions/{id}/har

Parameters

Name

Type

Mandatory

Description

tokenStringYesAccess Key


See  Performance Pipeline for more details 


Code Example


The examples below using the Unirest HTTP library.  To compile and run them, use the following Maven dependency:


Maven dependency
<dependency>
    <groupId>com.mashape.unirest</groupId>
    <artifactId>unirest-java</artifactId>
    <version>1.4.9</version>
</dependency>



Java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
import org.junit.Test;

import java.io.InputStream;


import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
import org.junit.Assert;
import org.junit.Test;
 
import java.io.*;
import java.util.List;


public class APIConfluenceTransactions {
    private HttpResponse<String> responseString;
    private HttpResponse<InputStream> responseInputStream;

    private String urlBase = "<Reporter URL>";   //TODO: modify hostname and port of your Reporter

    private String user = "<User>";  //TODO: user name
    private String password = "<Password>";  //TODO: user password
    @Test
    public void deleteMultipleTransactions() {

        int from = 1;
        int to = 1000;
        int step = 100;


        for (int start = from; start< to; start=start+ step){
            System.out.println(start);
            StringBuffer toDelete =new StringBuffer(start+"");
            for(int i = start+1; i<start+ step; i++){
                toDelete.append(","+i);
            }
            deleteTranactions(toDelete.toString());
        }

    }

    private void deleteTranactions(String toDelete) {
        String url = urlBase + "/api/testtx/"+toDelete;

        try {
            responseString = Unirest.delete(url)
                    .basicAuth(user, password)
                    .queryString("projectName","default")
                    .header("content-type", "application/json")
                    .asString();

            System.out.println(responseString.getBody());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void testDowload() throws Exception {
    	String url= urlBase + "/api/transactions/%d/har";
    	long transId = <transaction id>;
    	String token = <...accesToken...>

        url = String.format(url, transId);
        HttpResponse<InputStream> response = Unirest.get(url)
                .queryString("token", token)
                .asBinary();
        int status = response.getStatus();
        Assert.assertEquals(200, status);
        if (status == 200) {
            List<String> disposition = response.getHeaders().get("Content-Disposition");
            String fileName = "harfile";
            if (!disposition.isEmpty()) {
                fileName = disposition.get(0).split("=")[1];
            }
            fileName = "/tmp/" + fileName;
            saveToFile(response.getBody(), fileName);
            Assert.assertTrue(new File(fileName).exists());
        }
    }
 
    static void saveToFile(InputStream in, String fileName) throws IOException {
        try (OutputStream out = new FileOutputStream(fileName)) {
            byte[] buffer = new byte[1024];
            int readCount;
            while ((readCount = in.read(buffer)) != -1) {
                out.write(buffer, 0, readCount);
            }
        }
    }
}




  • No labels