Forum Discussion
Thanks for adding request.
However, not sure what you mean by "take control of whole request into groovy script"?
The question is not clear whether you want to retrieve data or youo want to replace the data.
Also do specify which fields (or data) that needs to be worked on.
Or please give high level view of your use case or what you are trying to achieve?
Hi Rao,
I want to capture entire request into one variable , then access DepartureDateTime in the request with xpath and then replace it with new custom property value. Before doing that I would like to retrieve the value of the element using getNodeValue. But I am getting null value when I am trying to retrieve value of Departure Date Time element.
def saloffer = testRunner.testCase.testSteps["SAL_offer"].getPropertyValue("Request")
def salreqnode = new XmlHolder(saloffer);
def path = salreqnode.getNodeValue("//soapenv:Envelope/soapenv:Body//MerchOfferRequest/RequestCriterion/*:OriginDestinationOptions/*:FlightSegment/*:DepartureDateTime")
log.info path
Console output:
- Sun Apr 19 01:57:29 CDT 2020:INFO:null
- nmrao5 years agoChampion Level 3Can you please answer my previous question?
- nmrao5 years agoChampion Level 3
Here you go:
//Pass the xml as request variable def departureDate = new XmlSlurper().parseText(request).'**'.find {it.name() == 'DepartureDateTime'}.text() log.info departureDate
You can test this online here https://www.ideone.com/ZJfPLa
Related Content
- 5 years agoRahul12
Recent Discussions
- 22 hours agoruchisingh