Forum Discussion

debanjan's avatar
debanjan
Occasional Contributor
8 years ago

How can I assert a json parameter in Request with a XML response through Script Assertion in Soap UI

I am using SoapUI version 5.3.0 My Application have a couple of RESTful APIs. I am sending multiple request to a WebService in the form of a json request as below:   { "app_key":"i8gAVDwcAq40n2kAv...
  • HKosova's avatar
    8 years ago

    You need to use context.expand to do property expansions in scripts:

    context.expand('${#TestCase#TARGET_DB}'))

    or you can access test case properties as follows:

    context.testCase.getPropertyValue("TARGET_DB")
    context.testCase.properties["TARGET_DB"].value

     

    Alternatively it might be easier to use the XPath Match assertion instead of the Script assertion:

    XPath expression: //*:RequestNumber

    Expected result: ${#TestCase#TARGET_DB}

  • HKosova's avatar
    HKosova
    8 years ago

    @debanjan, these expressions should be used in place of "${TARGET_DB}", that is:

    if (nodeRequestNumber == context.expand('${#TestCase#TARGET_DB}'))

    or

    if (nodeRequestNumber == context.testCase.getPropertyValue("TARGET_DB"))

    or

    if (nodeRequestNumber == context.testCase.properties["TARGET_DB"].value)