Forum Discussion

Aksingia's avatar
Aksingia
Occasional Contributor
8 years ago

Assertion and variable comparaison for a webservice

Hello,

 

I have a webservice which as //*:import_id_doc_stk in request part and has //*:export_id_doc_stk in response.
I won't explain the processing but I'd like to compare //*:import_id_doc_stk and //*:export_id_doc_stk in an assertion.

Is it possible? When I tried, it compared //*:export_id_doc_stk as if it is an actual string and not a variable.

 

Thank you for your help.

 

Edit: using a WSDL (calling mainframe) 

  • The XPath Match assertion can compare a request field with a response field. Assuming the request and response belong to the same test step, and assuming there's just one element "import_id_doc_stk" in the request and one element "export_id_doc_stk" in the response, you can configure XPath Match as follows:

     

    XPath Expression:

    //*:export_id_doc_stk

     

    Expected result:

    ${${=context.currentStep.label}#Request#//*:import_id_doc_stk}

    or if #Request# does not work:

    ${${=context.currentStep.label}#RawRequest#//*:import_id_doc_stk} 

    ${...} forces the expressions to be evaluated rather than treated as literal strings.

8 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    The XPath Match assertion can compare a request field with a response field. Assuming the request and response belong to the same test step, and assuming there's just one element "import_id_doc_stk" in the request and one element "export_id_doc_stk" in the response, you can configure XPath Match as follows:

     

    XPath Expression:

    //*:export_id_doc_stk

     

    Expected result:

    ${${=context.currentStep.label}#Request#//*:import_id_doc_stk}

    or if #Request# does not work:

    ${${=context.currentStep.label}#RawRequest#//*:import_id_doc_stk} 

    ${...} forces the expressions to be evaluated rather than treated as literal strings.

    • Aksingia's avatar
      Aksingia
      Occasional Contributor

      Seems to be not far off

      I tried (Créer Dossier = CurrentStep) :

      ${${=context.Créer Dossier.label}#Request#//*:import_id_doc_stk}

       

      but it says the expected value is []. Obviously I check th contained value using a property transfer and it's actually filled with [mystring]

      Do I have to modify context and label too?

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        "context.currentStep.label" is a code expression that refers to the current step, there's no need to change anything there.

         

        If you want to refer to a step by name (whether the current step or another one), use this syntax instead:

        ${Créer Dossier#Request#//*:import_id_doc_stk}