It looks like it makes sense, just like post#2. But the problem is still the same: I cant (or dont know how to) apply it in this situation.
Extended the code:
import com.eviware.soapui.impl.wsdl.teststeps.*
import com.eviware.soapui.support.XmlHolder
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def steps = testRunner.testCase.getTestStepsOfType( WsdlTestRequestStep.class )
def project = testRunner.testCase.testSuite.project
for (step in steps) {
log.info step.name// + step.getLabel()
def holder1 = groovyUtils.getXmlHolder( step.testRequest.requestContent )
assert project.getPropertyValue("objectid") != null, "no objectid set"
// holder1["//Les/ObjectID"]=project.getPropertyValue("objectid")
// holder1["//LesCreate/ObjectID"]=project.getPropertyValue("objectid")
// holder1["//LesDelete/ObjectID"]=project.getPropertyValue("objectid")
def nodes = holder1.getDomNodes("//ObjectID/parent::*[contains(name(), \"Les\")]")
log.info "new value "+project.getPropertyValue("objectid")
for(int i = 0; i < nodes.length-1 ; i++) {
def elems = nodes[i].getChildNodes();
for(int j = 0; j < elems.length-1 ; j++) {
def child = elems.item(j);
log.info "child $j "+ child
if( child.getNodeName() == "ObjectID") {
log.info "YES! we got one! Now the new value: "
child.setNodeValue(project.getPropertyValue("objectid"))
log.info child.getNodeValue()
}
}
}
holder1.updateProperty()
step.testRequest.setRequestContent (holder1.getXml());
}
Problems:
1) The last print
log.info child.getNodeValue()
does print null. And no, the project.getPropertyValue("objectid") does not return null.
2) the XML code of the test request has not changed.
3) The node "Les" does NOT match the Xpath expression
4) It is slightly better as parsing the whole document yourself but.... barely. It is a mess compared to a simple sed -e 's/Les(.*)\/ObjectID/.... . You get the meaning, in lots of languages this is a one statement string replace with a reg ex.