Introduction to New Transaction APIs

Micro Focus Contributor
Micro Focus Contributor
1 0 862

Two new JSAPIs are added to TruClient:

  • setTransationStatus
    Sets the default end status of all open transactions.
  • setTransationStatusByName
    Sets the default end status of a single open transaction by the transaction name.

api-321x250_256x128.jpgPreviously, you can only specify the transaction status in endTransaction API. You’re not able to specify different statuses in different situations during replay. Now, the setTransationStatus and setTransationStatusByName APIs give you the ability to change the status explicitly and dynamically.

 

Here is an example:

Step 1: TC.startTransaction(“T1”)

Step 2: navigate to a web page

Step 3: click button “B1”

Step 4: TC.endTransaction(“T1”, “Pass”)

If you want to do some check between step 2 and step 3, change the transaction status according to the check result, and then continue to step 3,  you can change the script like this (also remember to change the “On Error” option in RTS/GS to resume) :

Step 1: TC.startTransaction(“T1”)

Step 2: navigate to a web page

Step 3: if (condition) {TC.setTransactionStatus(“Pass”);}

              else {TC.setTransactionStatus(“Fail”);}

Step 4: click button “B1”

Step 5: TC.endTransaction(“T1”, “Auto”)

Please note that the status specified in the endTransaction API should be “Auto”, otherwise,  setTransactionStatus will not take effect.

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.