Forum Discussion

coopernico46's avatar
coopernico46
Occasional Contributor
7 years ago

Can't extract a value from a label to a Property

Hi all

 

I'm newbie with SOAP and i'm having problems when i try to extract a value from a label to a Property.

 

I have this already done for other steps but in this case i don't know what i'm doing wrong.

 

To help you to understand my problem let me insert my Response and also my Script Assertion (that is failing right now):smileyfrustrated:

 

This is my repsonse

<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://xxxx.com/Interfaces/SailingList">
         <alpha:OTA_CruiseSailAvailRS MaxResponses="20" MoreDataEchoToken="2018-08-0307PANTLMO" 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="5" Start="2018-07-06" 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-07" Status="36">
                     <alpha:CruiseLine ShipCode="MO" VendorCode="PUL"/>
                     <alpha:Region RegionCode="PISGR" SubRegionCode="PAC"/>
                     <alpha:DeparturePort LocationCode="CTG"/>
                     <alpha:ArrivalPort LocationCode="CTG"/>
                  </alpha:SelectedSailing>
                  <alpha:InclusivePackageOption CruisePackageCode="MOPS0783" InclusiveIndicator="false"/>
               </alpha:SailingOption>
            </alpha:SailingOptions>
         </alpha:OTA_CruiseSailAvailRS>
      </list:getSailingListResponse>
   </soapenv:Body>
</soapenv:Envelope>

And this is my Assertion Script

 

def CruisePackageCodeToChoose = new XmlSlurper().parseText(context.response)."**".find{ 
	it.SelectedSailing."**".find{
		            it.'@RegionCode'.text() == "PANTL"
	}
 }InclusivepackageOption.@CruisePackageCode?.text()

context.testCase.setPropertyValue('CruisePackageCode', CruisePackageCodeToChoose)

The Assertion message is "Script Assertion Passed" but the property CruisePackageCode (at a TestCase level) is not populated with the value of @CruisepackageCode, that is MOPS0780

 

 

Thanks in advance for your support.

 

  • coopernico46's avatar
    coopernico46
    7 years ago

    Hi All

     

    Finally i solve my problem.

     

    Here you have the code cause maybe someone could have the same question in a future.

    def CruisePackageCodetoChoose = new XmlSlurper().parseText(context.response)."**".find{ 
    	it.SelectedSailing.Region.find{
    				            it.'@RegionCode'.text() == "PISGR"
    			}
     }.InclusivePackageOption.@CruisePackageCode?.text()
    context.testCase.setPropertyValue('CruisePackageCode', CruisePackageCodetoChoose)

     

    Best regards

  • coopernico46's avatar
    coopernico46
    Occasional Contributor

    Hi All

    Any idea? i'm trying different ways to extract but neither of its works as expected.

    • coopernico46's avatar
      coopernico46
      Occasional Contributor

      Hi All

       

      finally i solve my problem.

       

      Here you have the code cause maybe someone could have the same question in a future.

      def CruisePackageCodetoChoose = new XmlSlurper().parseText(context.response)."**".find{ 
      	it.SelectedSailing.Region.find{
      				            it.'@RegionCode'.text() == "PISGR"
      			}
       }.InclusivePackageOption.@CruisePackageCode?.text()
      context.testCase.setPropertyValue('CruisePackageCode', CruisePackageCodetoChoose)

       

      Best regards

    • coopernico46's avatar
      coopernico46
      Occasional Contributor

      Hi All

       

      Finally i solve my problem.

       

      Here you have the code cause maybe someone could have the same question in a future.

      def CruisePackageCodetoChoose = new XmlSlurper().parseText(context.response)."**".find{ 
      	it.SelectedSailing.Region.find{
      				            it.'@RegionCode'.text() == "PISGR"
      			}
       }.InclusivePackageOption.@CruisePackageCode?.text()
      context.testCase.setPropertyValue('CruisePackageCode', CruisePackageCodetoChoose)

       

      Best regards