Karate: [question / unexpected behavior] populating XML template in called feature

Created on 24 May 2017  路  4Comments  路  Source: intuit/karate

We have a reusable feature my-soap-action.feature that is being called with a list of arguments from another feature, i.e. looping and passing arguments to a child feature:

* def result = call read('./my-soap-action.feature') myJsonArray

Inside of my-soap-action.feature, we call * def request = read('./my-xml-template.xml') and execute the soap request.

I am able to see / print each of the array elements as they are passed as arguments. However, when the request body is created, com.intuit.karate#evalXmlEmbeddedExpressions is using the context of the call site in the parent feature and not the context of my-soap-action.feature. Our template variable is undefined in the parent and the script fails.

What is the proper way to evaluate a template like this? The behavior I was expecting is that the template would be evaluated with the context of the file in which the XML template is read.

Thank you so much, we love this framework! :)

bug

All 4 comments

will take a look. congratulations @james-mcelwain for being the 200-th person to 'star' this project :)

@james-mcelwain for the time being you can work around by using the set keyword, something like this:

* def request = read('./my-xml-template.xml')
* set request /some/xpath = someVariableFromArgs

released 0.4.1

@ptrthomas Yay! Thank you so much!

Was this page helpful?
0 / 5 - 0 ratings