How can i find a @param that matches with a textCase property value?
Hi all
Sorry for the inconvenances but, after thousands of attemps i really need your help
My problem is that i'm trying to find (with a groovy script assertion ) a Param that matches with the value previously defined at a testCase level
Let me attach more details to let you understand what i'm trying to do
This is my Response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <list:getSailingListResponse xmlns:alpha="http://www.opentravel.org/OTA/2003/05/alpha" xmlns:list="http://xxxxxx/SailingList"> <alpha:OTA_CruiseSailAvailRS MaxResponses="20" MoreDataEchoToken="2018-07-3007PANTLMO" MoreIndicator="true" SequenceNmbr="0" Version="1.0"> <alpha:Success/> <alpha:Warnings> <alpha:Warning Type="3"/> </alpha:Warnings> <alpha:SailingOptions> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="7" Start="2018-06-30" Status="36"> <alpha:CruiseLine ShipCode="ZE" VendorCode="PUL"/> <alpha:Region RegionCode="PFIOR" SubRegionCode="PFI"/> <alpha:DeparturePort LocationCode="RLG"/> <alpha:ArrivalPort LocationCode="TRD"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="ZEPF0738" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="6" Start="2018-07-02" Status="36"> <alpha:CruiseLine ShipCode="HR" VendorCode="PUL"/> <alpha:Region RegionCode="PISGR" SubRegionCode="PGR"/> <alpha:DeparturePort LocationCode="ATH"/> <alpha:ArrivalPort LocationCode="ATH"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="HRPT0732" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="6" Start="2018-07-02" Status="36"> <alpha:CruiseLine ShipCode="SO" VendorCode="PUL"/> <alpha:Region RegionCode="PMARA" SubRegionCode="PDC"/> <alpha:DeparturePort LocationCode="BCN"/> <alpha:ArrivalPort LocationCode="BCN"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="SOPD0730" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P14N" PortsOfCallQuantity="9" Start="2018-07-07" Status="36"> <alpha:CruiseLine ShipCode="ZE" VendorCode="PUL"/> <alpha:Region RegionCode="PEXPD" SubRegionCode="PDD"/> <alpha:DeparturePort LocationCode="TRD"/> <alpha:ArrivalPort LocationCode="TRD"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="ZEPN1407" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="6" Start="2018-07-09" Status="36"> <alpha:CruiseLine ShipCode="HR" VendorCode="PUL"/> <alpha:Region RegionCode="PISGR" SubRegionCode="PGR"/> <alpha:DeparturePort LocationCode="ATH"/> <alpha:ArrivalPort LocationCode="ATH"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="HRPT0732" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="5" Start="2018-07-13" Status="36"> <alpha:CruiseLine ShipCode="MO" VendorCode="PUL"/> <alpha:Region RegionCode="PANTL" SubRegionCode="PAC"/> <alpha:DeparturePort LocationCode="ONX"/> <alpha:ArrivalPort LocationCode="ONX"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="MOPS0780" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="5" Start="2018-07-14" Status="36"> <alpha:CruiseLine ShipCode="MO" VendorCode="PUL"/> <alpha:Region RegionCode="PANTL" SubRegionCode="PAC"/> <alpha:DeparturePort LocationCode="CTG"/> <alpha:ArrivalPort LocationCode="CTG"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="MOPS0783" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="5" Start="2018-07-16" Status="36"> <alpha:CruiseLine ShipCode="MO" VendorCode="PUL"/> <alpha:Region RegionCode="PANTL" SubRegionCode="PAC"/> <alpha:DeparturePort LocationCode="CUR"/> <alpha:ArrivalPort LocationCode="CUR"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="MOPS0794" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="6" Start="2018-07-16" Status="36"> <alpha:CruiseLine ShipCode="SO" VendorCode="PUL"/> <alpha:Region RegionCode="PMARA" SubRegionCode="PDC"/> <alpha:DeparturePort LocationCode="BCN"/> <alpha:ArrivalPort LocationCode="BCN"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="SOPD0730" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="7" Start="2018-07-16" Status="36"> <alpha:CruiseLine ShipCode="HR" VendorCode="PUL"/> <alpha:Region RegionCode="PMEVS" SubRegionCode="PMV"/> <alpha:DeparturePort LocationCode="ATH"/> <alpha:ArrivalPort LocationCode="TRS"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="HRPV0744" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="5" Start="2018-07-20" Status="36"> <alpha:CruiseLine ShipCode="MO" VendorCode="PUL"/> <alpha:Region RegionCode="PANTL" SubRegionCode="PAC"/> <alpha:DeparturePort LocationCode="ONX"/> <alpha:ArrivalPort LocationCode="ONX"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="MOPS0780" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="5" Start="2018-07-21" Status="36"> <alpha:CruiseLine ShipCode="MO" VendorCode="PUL"/> <alpha:Region RegionCode="PANTL" SubRegionCode="PAC"/> <alpha:DeparturePort LocationCode="CTG"/> <alpha:ArrivalPort LocationCode="CTG"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="MOPS0783" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="8" Start="2018-07-21" Status="36"> <alpha:CruiseLine ShipCode="ZE" VendorCode="PUL"/> <alpha:Region RegionCode="PFIOR" SubRegionCode="PFI"/> <alpha:DeparturePort LocationCode="TRD"/> <alpha:ArrivalPort LocationCode="RLG"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="ZEPF0741" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="5" Start="2018-07-23" Status="36"> <alpha:CruiseLine ShipCode="MO" VendorCode="PUL"/> <alpha:Region RegionCode="PANTL" SubRegionCode="PAC"/> <alpha:DeparturePort LocationCode="CUR"/> <alpha:ArrivalPort LocationCode="CUR"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="MOPS0794" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="6" Start="2018-07-23" Status="36"> <alpha:CruiseLine ShipCode="SO" VendorCode="PUL"/> <alpha:Region RegionCode="PMARA" SubRegionCode="PDC"/> <alpha:DeparturePort LocationCode="BCN"/> <alpha:ArrivalPort LocationCode="BCN"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="SOPD0730" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="7" Start="2018-07-23" Status="36"> <alpha:CruiseLine ShipCode="HR" VendorCode="PUL"/> <alpha:Region RegionCode="PMEVS" SubRegionCode="PMV"/> <alpha:DeparturePort LocationCode="TRS"/> <alpha:ArrivalPort LocationCode="ATH"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="HRPV0745" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="5" Start="2018-07-27" Status="36"> <alpha:CruiseLine ShipCode="MO" VendorCode="PUL"/> <alpha:Region RegionCode="PANTL" SubRegionCode="PAC"/> <alpha:DeparturePort LocationCode="ONX"/> <alpha:ArrivalPort LocationCode="ONX"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="MOPS0780" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="5" Start="2018-07-28" Status="36"> <alpha:CruiseLine ShipCode="MO" VendorCode="PUL"/> <alpha:Region RegionCode="PANTL" SubRegionCode="PAC"/> <alpha:DeparturePort LocationCode="CTG"/> <alpha:ArrivalPort LocationCode="CTG"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="MOPS0783" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="8" Start="2018-07-28" Status="36"> <alpha:CruiseLine ShipCode="ZE" VendorCode="PUL"/> <alpha:Region RegionCode="PFIOR" SubRegionCode="PFI"/> <alpha:DeparturePort LocationCode="RLG"/> <alpha:ArrivalPort LocationCode="TRD"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="ZEPF0736" InclusiveIndicator="false"/> </alpha:SailingOption> <alpha:SailingOption> <alpha:SelectedSailing ListOfSailingDescriptionCode="6" Duration="P7N" PortsOfCallQuantity="5" Start="2018-07-30" Status="36"> <alpha:CruiseLine ShipCode="MO" VendorCode="PUL"/> <alpha:Region RegionCode="PANTL" SubRegionCode="PAC"/> <alpha:DeparturePort LocationCode="CUR"/> <alpha:ArrivalPort LocationCode="CUR"/> </alpha:SelectedSailing> <alpha:InclusivePackageOption CruisePackageCode="MOPS0794" InclusiveIndicator="false"/> </alpha:SailingOption> </alpha:SailingOptions> </alpha:OTA_CruiseSailAvailRS> </list:getSailingListResponse> </soapenv:Body> </soapenv:Envelope>
And i want to get the Param REGIONCODE that matches with my TestCase property "Region_con_vuelo_a_elegir"
At the begining i have hardcoded the value of "Region_con_vuelo_a_elegir" (and the property doesn't exist) into the assertion, and i have no problems, all works fine for me, but now i'm trying to change the way i work, passing this hardcode value into from a value to allow other college to execute my script easily
My original code that works fine (PISGRis the current value that i have into an a property)
def DateItinWithFlights = new XmlSlurper().parseText(context.response)."**".find{
it.SelectedSailing."**".find{
it.'@RegionCode'.text() == "PISGR"
}
}SelectedSailing.@Start?.text()
context.testCase.setPropertyValue('SailingDate', DateItinWithFlights)
Now i'm trying with code like this
def Region_a_elegir = context.('${testCase#Region_con_vuelo_a_elegir') def DateItinWithFlights = new XmlSlurper().parseText(context.response)."**".find{ it.SelectedSailing.find{ it.Region.{ it.'@RegionCode'.text() == 'Region_a_elegir'.text() } } }SelectedSailing.@Start?.text() context.testCase.setPropertyValue('SailingDate', DateItinWithFlights)
the Assertion status is "passed" but the property "SailingDate" doen't reflect the value 2018-07-02 (that is the first valid value in the response attached for RegionCode=PISGR.
Please, could you help me?
Hi all
After some attemps, finally got the Solution from an old thread from 2015 where nmrao post the solution to my question.
So, Just to post the Solution, this is the code that solved my question
def DateItinWithFlights = new XmlSlurper().parseText(context.response)."**".find{ it.SelectedSailing."**".find{ it.'@RegionCode'.text() == context.testCase.getPropertyValue('Region_con_vuelo_a_elegir') } }SelectedSailing.@Start?.text() context.testCase.setPropertyValue('SailingDate', DateItinWithFlights)
Thanks