Introduction to New Transaction APIs
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Receive email notifications
- Email to a Friend
- Printer Friendly Page
- Report Inappropriate Content
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.
Previously, 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.