Ask a Question

Reference current Response-SOAP-XML in context.expand

SOLVED
DanielF
New Contributor

Reference current Response-SOAP-XML in context.expand

In my project I have many teststeps: TF001, TF002, TF003, …

These teststeps are organized in the testcase “getOffer”

I want to run these teststeps individually, as well as all together in the testcase.

For both these ways I want to do something special every time and with each response-xml: get a base64-element, decrypt it and write it to the harddrive

 

My understanding is that Events -> RequestFilter.afterRequest is the appropriate solution for my problem.

So far so good…

 

My question is how to reference the current response-xml (SOAP) and the specific element with the base64-data.

I want to have one Event-Filter-Script, which should work for all!

The following code works fine for the first teststep and only for the first step.

def rawFile = context.expand( '${TF001#Response#declare namespace gevo=\'http://www.bipro.net/namespace/gevo\'; declare namespace allg=\'http://www.bipro.net/namespace/allgemein\'; //gevo:Datei[1]/allg:Daten[1]}' )

How can I re-write this groovy code so it works for all? I must get rid of the “TF001”.

Can you please tell me how to do this?

 

The following attempts did not work

def rawFile = context.expand( '${SOAP Request#Response...

def rawFile = context.expand( '${#TestStep#Request#Response...

2 REPLIES 2
KarelHusa
Champion Level 3

@DanielF,

use only: 

context.expand( '${Response...

 

For instance:

context.expand( '${Response#declare namespace tem="http://learnwebservices.com/services/tempconverter"; //tem:TemperatureInFahrenheit}')

I have tested this code in TestRunListener.afterStep.

 

Karel@apimate.eu
https://apimate.eu
DanielF
New Contributor

Thanks @KarelHusa for your response - that's what I was looking for! 🙂

 

At first it didn't work in my project, hence an additional hint:

Im my usecase where I want to run the request individually as well as grouped in a testcase I have to duplicate the code and use it in both these filters:

  • RequestFilter.afterRequest (for individual running)
  • TestRunListener.afterStep (for running in a testcase)
cancel
Showing results for 
Search instead for 
Did you mean: