Forum Discussion
Thanks Rup!!
This is what I was looking for. But how to parameterize both xpath and and node value. Lets say, I am taking this xpath (envelopeNode.Body.Add.intA) as a input parameter from excel sheet and then modifying the value to '20'.
def sIntA=envelopeNode.Body.Add.intA // Lets say, this value is taken from excel sheet (I have a code to get the value from excel sheet)
My aim is to get the Node's xpath from excel sheet, get the Node's value from excel sheet, update the xml with this node and save updated xml in a different folder.
Please suggest.
Hi,
Thats ok.
I think I now get what you are after i.e. a way to pass the actual (XPath) query in as a String paramter, but before having a go at that, can I ask if you actually just want a way to parameterise and populate SOAP requests from your spreadsheet of values e.g. data-driven testing? If this is the case I can potentially explain an easier way to do this in SoapUI using your spreadsheet.
Cheers,
Rup
- vikram_966910 years agoOccasional Contributor
Yes Rup. I am actually looking for data driven testing. I am trying to use external xml stored on local disc. I will update the node values using xpath. After updating the xml, I will save it in different folder and at the end I will upload both request xml and response xml to the test case in ALM. It helps me keeping track of request and response used for specific test case.
Please let me know if you have any easier way to do this.
Really appreciate your help. Thanks!
Cheers,
Vikram
- rupert_anderson10 years agoValued Contributor
Hi Vikram,
Ok, that sounds interesting. I don't know much about ALM, but hopefully we can sort something out.
So a common pattern of data-driven testing in SoapUI can be:
1. Read line of CSV data or potentially a soap request (using Groovy) in your case. You can do this in a Groovy TestStep. Say you have read the values in you can set them as properties on the context holder e.g.
context["intA"]=2
context["intB"]=3
2. Setup a SOAP Request TestStep and use the properties from the context holder to parameterise the SOAP request. You can esily insert the values using whats called property expansions (see http://www.soapui.org/scripting---properties/property-expansion.html) e.g.
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope">
<soap:Header/>
<soap:Body>
<tem:Add xmlns:tem="http://tempuri.org">
<tem:intA>${intA}</tem:intA>
<tem:intB>${intB}</tem:intB>
</tem:Add>
</soap:Body>
</soap:Envelope>2a) You can also use the data values from the context to parameterise Assertions e.g. XPath Assertion (expected value) or Content or Script Assertions.
3. Use another Groovy TestStep (there is also a Conditional Goto TestStep) to loop back to 1 if there are more rows of test data.
Of course if you want to dump the SOAP request/response into a file, the thats easy enough to add with Groovy.
Does this sound at all like what you wanted? It just sounded like it might be easier to work with data values e.g. CSV rather than having to manipulate XML with XPaths..
If this is not really what you need, we can get back to the plan A and I'll have a go at adapting that Groovy script to use XPaths instead.
Cheers,
Rup
- amitavban6 years agoNew Contributor
Hi Rupert,
I am also facing a similar problem but the difference is that I am not doing SOAPUI testing but I need to update the SOAPUI response tag values from an excel before forwarding that response to another system ,since my main application is developed in groovy ,I was thinking if this can be done in groovy only.
So my excel header are actually XPATHS and the corresponding rows below contain the value.
any help would be great.
Related Content
- 5 years ago
Recent Discussions
- 3 days ago