Forum Discussion

deonvisser12's avatar
deonvisser12
Regular Visitor
8 years ago

How to trim a value if I compare to services in an assertion?

Hi all

I have a web service and a new rest service.I want to confirm that nothing has change with the new rest service.

If I compare the web service as an example "frist name" the service returns "Gareth" and the new rest service returns

"Gareth            " with spaces at the back.

My assersion as follow

my jsonPath expression =    $[0].cms.firstName

And expected result       =    ${Request 1#ResponseAsXml#//Response[1]/e[1]/cms[1]/firstName[1]}

 

How do I trim this assertion?

Please see screen shot because I don't know with this where in my expression to put the trim()

1 Reply

  • nmrao's avatar
    nmrao
    Champion Level 3
    The value retrieved from Json needs to be trimmed. Not sure if JSONPath allows to do so.
    A Script Assertion can do this.