Forum Discussion

saprao's avatar
saprao
Occasional Contributor
12 years ago

Needs to validate Range of values in response

Hi,

Could you please help me out any one for validate range of values in response xml through xpath assertion or any other assertion if possiable.

Ex : I am passing date ='2013-08-05' value through request xml then getting response....date values is greater than or equal to input date value. so, here i need to validate date is greater than or equal to input date values in reqonse xml then my xpath assertion should be pass.

For validate above response value of date, how to write my condition in xpath assertion? please provide me detail xml.

Attached sample request and response xml in spreed sheet
  • Here is the xpath you may use which will return true in your case.
    number(translate(string(//alpha:SelectedSailing/@Start),'-','')) >= number(translate('2014-05-11','-',''))
  • saprao's avatar
    saprao
    Occasional Contributor
    Response XML

    <soapenv:Body>
    <list:getSailingListResponse xmlns:alpha="http://www.opentravel.org/OTA/2003/05/alpha" xmlns:list="http://services.rccl.com/Interfaces/SailingList">
    <alpha:OTA_CruiseSailAvailRS MaxResponses="9" MoreDataEchoToken="2014-08-0812EUROPJR" MoreIndicator="false" 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="6" Start="2014-05-12" Status="36">
    <alpha:CruiseLine ShipCode="JR" VendorCode="AZA"/>
    <alpha:Region RegionCode="EUROP" SubRegionCode="EME"/>
    <alpha:DeparturePort LocationCode="ATH"/>
    <alpha:ArrivalPort LocationCode="ROM"/>
    </alpha:SelectedSailing>



    Below path i have given in the XPATH... but it is not working
    ${Sailings_Request#Response#declare namespace list='http://services.rccl.com/Interfaces/SailingList'; declare namespace alpha='http://www.opentravel.org/OTA/2003/05/alpha'; //list:getSailingListResponse[1]/alpha:OTA_CruiseSailAvailRS[1]/alpha:SailingOptions[1]/alpha:SailingOption[1]/alpha:SelectedSailing[1]/[xs:Start(@Start) ge xs:Start('2014-05-11')}
  • nmrao's avatar
    nmrao
    Champion Level 3
    Here is the xpath you may use which will return true in your case.
    number(translate(string(//alpha:SelectedSailing/@Start),'-','')) >= number(translate('2014-05-11','-',''))
    • pavak's avatar
      pavak
      Occasional Contributor

      does this works in JSON? 

      also, what changes do I need to make in xpath(JSONpath) if I need to add assertion to range.

      Ex: I need to see my dates are in between "2014-02-01T00:00:00-05:00" to "2014-02-28T00:00:00-05:00"

       

      Please help me with that.

       

      Thanks.

      • nmrao's avatar
        nmrao
        Champion Level 3
        It is encouraged not to cross post. May be you want to do in a new topic?