Forum Discussion
Solution will dependent on that.
Hi NMRao,
Here is full request. I would like to take control of whole request into groovy script and replace some element values with Custom Properties defined at Test Suite level. When I am executing the groovy script now its returning null value. I have attached my groovy script.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.united.com/merch/services">
<soapenv:Header/>
<soapenv:Body>
<MerchOfferRequest TransactionIdentifier="55678" TransactionLog="true">
<RequestCriterion>
<OriginDestinationOptions Id="OD1">
<FlightSegment ActiveInd="Y" Id="1">
<DepartureAirport LocationCode="IAH"/>
<ArrivalAirport LocationCode="DEN"/>
<DepartureDateTime>dfdf</DepartureDateTime>
<ArrivalDateTime>2020-12-01T19:00:00</ArrivalDateTime>
<FlightNumber>863</FlightNumber>
<OperatingAirline>UA</OperatingAirline>
<MarketingAirline>UA</MarketingAirline>
<SegmentNumber>1</SegmentNumber>
<ClassOfService>Y</ClassOfService>
<TripIndicator>C</TripIndicator>
<SegmentStatus>HK</SegmentStatus>
<IsSeatMapPricing>false</IsSeatMapPricing>
</FlightSegment>
</OriginDestinationOptions>
<TravelerInfo>
<Traveler HostIndex="1.1">
<Id>1</Id>
<GivenName>THREESILVER</GivenName>
<Surname>TESTER</Surname>
<PassengerTypeCode>ADT</PassengerTypeCode>
<!--<TravelerCategory>MET</TravelerCategory>-->
<Gender>Unknown</Gender>
<TicketingDate>2020-03-25T00:00:00</TicketingDate>
<TicketNumber/>
</Traveler>
</TravelerInfo>
<IncludeExcludeOffers>
<ServiceFilterCode ServiceCode="BAG" ResultAction="Include"/>
</IncludeExcludeOffers>
<!--<BookingReferenceIds BookingReferenceId="CDBZ7L"/>-->
</RequestCriterion>
<Requestor ChannelId="101" CurrencyCode="" ChannelName="OBE" CountryCode="US" TicketingCountryCode="US"/>
</MerchOfferRequest>
</soapenv:Body>
</soapenv:Envelope>
- nmrao5 years agoChampion Level 3
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?
- sonya_m5 years agoSmartBear Alumni (Retired)
Hi satishdurugu, it looks like you replied to the email - this way your answer won't reach the Community. Please copy the answer here, thank you!
- satishdurugu5 years agoNew Contributor
Hi Rao,
I would like to capture the Request property in the groovy script and replace the DateofDeparture Element value with custom property value defined at Test Suite level and run the updated request.
Thanks,
Satish
- nmrao5 years agoChampion Level 3Still unclear use case. Are you sending the same request two times with different dates like CREATE, UPDATE? or you want to send current date always?
You can use property expansion though if you have the value already in custom property. Please refer documentation
https://www.soapui.org/scripting-properties/property-expansion.html
- satishdurugu5 years agoNew Contributor
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 pathConsole output:
- Sun Apr 19 01:57:29 CDT 2020:INFO:null
- nmrao5 years agoChampion Level 3Can you please answer my previous question?
Related Content
- 5 years ago
- 12 months ago
Recent Discussions
- 15 years ago