Forum Discussion
Hi richie
Thank you very much for your reply and for your help. I will try to explain myself more clearly.
- My goal is to source specific tag values in my xml-file from a excel-sheet. For instance with this example request (without header, see below). As you can see i already tagged and generated the values from a DataBase (Excel). Now some of the values will be empty in the Excel Sheet. Now ReadyAPI correctly shows the empty elements like you described:
- <v13:FirstName>
<v13:PrimaryValue>${TestData_DataEntry#FirstName}</v13:PrimaryValue>
</v13:FirstName> - =
- <v13:FirstName/> <----- = empty
Now i need from SoapUIpro to delete these "nested tags" when a request is sended. I have selected "Remove Empty Content " as "true". But it only deletes partially of the tags. It only deletes the "PrimaryValue" and leaves FirstName. I need SoapUI to delete the whole tag and not only "PrimaryValue"
Thank you very much for your help. If you need further specification pls let me know
- ChrisAdams4 years agoChampion Level 3
Hi,
"Is there no other way to delete parent elements?". Sorry, I really don't know.
I've used SoapUI's data driven test functionality extensively. In the main, my test data wholly aligns to the payload, so I usually don't have to worry about empty nodes and having to remove them.
On the flip side, I have built validation tests where I'm checking for the existence (and non-existence) of nodes as well as testing expected response where some node is empty.
For this, I still use data-driven tests, but instead of squirting in individual values, I've squirted in the whole request. I've also used data driven tests where my Excel data is a path to a file and I've 'pulled in' the file contents using a Groovy script step. The files contain the whole request I want to send.
To sum up, whilst SoapUI may not always offer what you need, I've never not been able to use the functionality to work around such limitations.
- ZDGN4 years agoContributor
Hi DavidSEM_Admin,
ChrisAdams is pointing something that I find really interesting.
As far as I understand, you could use some groovy code to dynamically generate your xml content depending on the values extracted form your excel file.
That is to say that you keep your data driven test step, and then use groovy code to add or not xml element to the request.
This should make the deal for you.
David.
- DavidSEM_Admin4 years agoOccasional Contributor
HIZDGN
i also found that a groovy script would possible help. However, I have no idea how to write such a groovy code to make it work.
Could you tell me how or do you have such a working groovy code?
- DavidSEM_Admin4 years agoOccasional Contributor
ChrisAdams can you show or give an example how you did this?
"For this, I still use data-driven tests, but instead of squirting in individual values, I've squirted in the whole request. I've also used data driven tests where my Excel data is a path to a file and I've 'pulled in' the file contents using a Groovy script step. The files contain the whole request I want to send."
i am not sure that I get this possible solution right...
- richie4 years agoCommunity HeroHey DavidSEM_Admin,
If youre running ReadyAPI!, you could create an event handler to strip out the empty elements after the data has been extracted from your source but before its injected via your REST request, so you wouldnt have to build the xml using groovy.
For the event handler groovy youd just need to identify the xpath of the attributes you want stripped.
Ta
Rich- DavidSEM_Admin4 years agoOccasional Contributor
HI richie
Thank you for your answer. Could you explain a little more about your idea with the event handler? I am using ReadyAPI 3.3.1.
I did an event handler with the mentioned script in my previous messages in this topic. I did an event "RequestFilter.filterRequest" and it didn't work. What went wrong?
This was the script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def stepName = context.getCurrentStep().getLabel()
def holder = groovyUtils.getXmlHolder(stepName + "#Request")for( item in holder.getDomNodes( "//*[. = '']" )){
holder.removeDomNodes("//"+item.nodeName)
}
Related Content
- 3 years ago
Recent Discussions
- 15 years ago
- 6 days ago
- 6 days ago