Using getXMLHolder with parameters?
I've seen tons of examples of getXMLHolder calls passing the teststepname#request or teststepname#response and that works fine. However, my input XML arrives via CSV file and gets assigned to DataSourceCsv#xml. I can log DataSourceCsv#xml and it contains the right stuff, e.g.
<transaction><apiname>DoSomething</apiname><company>3457714</company><house>100258</house><cust>1</cust><opr>INF</opr><lockpid>0</lockpid></transaction>
I have to update the lockpid value before executing the request, doing getXmlHolder, then holder["//lockpid"] = whatever. I have tried:
def holder = groovyUtils.getXmlHolder("DataSourceCsv#xml");
and then created a test case param and set its value to DataSourceCsv#xml and tried
def holder = groovyUtils.getXmlHolder("paramXML");
and
def holder = groovyUtils.getXmlHolder( '${#TestCase#paramXML}');
All result in "org.apache.xmlbeans.XmlException: error: Unexpected element CDATA error at line X". Do I have to manipulate my param in some way so getXmlHolder likes it, or is there a completely different way to do this when you don't have static XML?
I don't use the XML holder to manipulate XML so there may be a better way to use it, but the holder has a "getXml()" method which returns a string so you should be able to do something like.
testRunner.testCase.setPropertyValue("paramXML", holder.getXml())
The holder is an instance of the XmlHolder class.
(As an aside I use the XmlSlurper and XmlParser to manipulate XML I personally find it a little bit more intuitive than the groovy utils / XML holder method.)