cancel
Showing results for 
Search instead for 
Did you mean: 

Property Transfer Conditional

SOLVED
Highlighted
Community Leader

Re: Property Transfer Conditional

Hey @nmrao  :

 

It would be glad if you please share any documentation for tutorial for below code snippet:

 

def catDispo = new XmlSlurper().parseText(context.response).'**'.find {it.name() == 'DefCategoriesDispo' && it.StatutDispo == true}

what is the use of ** and also .find{} in this. 

 

 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" 🙂

Thanks and Regards,
Himanshu Tayal
Highlighted
Community Hero

Re: Property Transfer Conditional

Hope you read the comment along with the code snippet.

Suggest you to read groovy documentation.

http://groovy-lang.org/documentation.html



Regards,
Rao.
Highlighted
Occasional Contributor

Re: Property Transfer Conditional

Hi,

I want to do the same with another Test suite, here's the assertion script : 

assert context.response, 'Response is empty or null'
// Permet de trouver la première catégorie avec une dispo
def catDispo = new XmlSlurper().parseText(context.response).'**'.find {it.name() == 'CategorieDispo' && it.Statut == O}

//Récupère la catégorie et la stock dans une custom property
context.testCase.setPropertyValue('CATCODE', catDispo.CategorieGroup.text())

And here the request response : 

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <DispoResponse xmlns="http://www.hitech.fr/">
         <DispoResult>
            <Demande>
               <StationDepart>U1194</StationDepart>
               <DateDepart>2020-05-18T10:00:00Z</DateDepart>
               <StationRetour>U1194</StationRetour>
               <DateRetour>2020-05-19T10:00:00Z</DateRetour>
            </Demande>
            <Categories>
               <CategorieDispo>
                  <CategorieGroup>M1</CategorieGroup>
                  <Statut>N</Statut>
               </CategorieDispo>
               <CategorieDispo>
                  <CategorieGroup>M2</CategorieGroup>
                  <Statut>N</Statut>
               </CategorieDispo>
               <CategorieDispo>
                  <CategorieGroup>M3</CategorieGroup>
                  <Statut>O</Statut>
               </CategorieDispo>
            </Categories>
         </DispoResult>
      </DispoResponse>
   </soap:Body>
</soap:Envelope>

I want to transfer the <CategorieGroup>M3</CategorieGroup> if only the statut is O

 

Thanks !

 
 
  •  
Highlighted
Community Hero

Re: Property Transfer Conditional

Yes. One can just relate it easily to existing solution. Nice!



Regards,
Rao.
Highlighted
Occasional Contributor

Re: Property Transfer Conditional

Hi, 

 

When I use ${#TestCase#CATCODE}, I can't retrieve the data, blank data..

Highlighted
Community Hero

Re: Property Transfer Conditional

Sorry didn't check in detail. Thought you posted the solution using existing one.

You got a trivial error. enclose O between single quotes like 'O'


Regards,
Rao.

View solution in original post

New Here?
Join us and watch the welcome video:
Read the Latest News
JuneSCNJ
Top Kudoed Authors