Ask a Question

Assertion and variable comparaison for a webservice

SOLVED
Aksingia
Occasional Contributor

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) 

1 ACCEPTED SOLUTION

Accepted Solutions
HKosova
Moderator

Re: Assertion and variable comparaison for a webservice

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.


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

8 REPLIES 8
nmrao
Community Hero

Re: Assertion and variable comparaison for a webservice

Not enough details to offer any help.


Regards,
Rao.
HKosova
Moderator

Re: Assertion and variable comparaison for a webservice

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.


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

Aksingia
Occasional Contributor

Re: Assertion and variable comparaison for a webservice

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
Moderator

Re: Assertion and variable comparaison for a webservice

"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} 

Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Aksingia
Occasional Contributor

Re: Assertion and variable comparaison for a webservice

Thank you, working.

Aksingia
Occasional Contributor

Re: Assertion and variable comparaison for a webservice

Not same question, but related to the command.

I'm using this for comparaison
${Créer Dossier#Response#//*:export_id_dos_doc} 

 

It's filled with [95]  (max size is 18 digits number), but when I compare it with //*:export_id_dos_doc containing [95], it tells me:

[....], expecting [95 ], actual was [95]

 

Any idea why it would give me a space? there is actually no spaces (otherwise my CICS program behind would have gone berzerk 😄 )

HKosova
Moderator

Re: Assertion and variable comparaison for a webservice

Check the Expected Result field in the assertion config and remove any trailing spaces/newlines.


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Aksingia
Occasional Contributor

Re: Assertion and variable comparaison for a webservice

Smiley Frustrated thank you very much for your time 

cancel
Showing results for 
Search instead for 
Did you mean: