groovysoapuiready-api

How to trim (space) the variables in the the assertion section in SoapUI?


How to trim (leading and trailing spaces) the variables in the the assertion section of SoapUI/ReadyAPI ?

Ex:
Input String : "Failure   "
Output String : "Failure"

Ready API Assertion Popup


Solution

  • After some research, I got the XSLT/XPath method which does space trim of given variables in Assertion window.

    Method name: normalize-space()

    Usage would be like:

    normalize-space(//Results[1]/ResultSet[1]/Row[1]/PAYMNT_RQST.PAYMNT_STAT_CD[1])
    

    normalize-space function collapses whitespace in a string. Specifically, it performs three steps:

    1. Replaces each carriage return (#xD), line feed (#xA), and tab (#x9) character with a single space (#x20)
    2. Collapses all consecutive spaces into a single space
    3. Removes all leading and trailing spaces