Forum Discussion

mpw83's avatar
mpw83
Contributor
6 years ago
Solved

Set the value of a test case property on xpath in property transfer

I m trying to add a property transfer from rest response to a test case level custom property. From rest response, I want to exact 'id' by 'name' and set the value as test case level property
My XPath is as follows 

//*:e[*:name = '${#TestCase#CLContractName}']/*:id

But this is returning null 
If I directly set the value then it's setting the value correctly 

//*:e[*:name = 'BY-12223']/*:id

My sample xml as follows 

<Response xmlns="https://training-app.labs.com/api/v1/investor">
<items>
<e>
<id>48223</id>
<name>LAI-00151007</name>
<amount>25050.0</amount>
<interest_rate>25.99</interest_rate>
<term>60</term>
</e>
<e>
<id>48262</id>
<name>LAI-00152581</name>
<amount>44225.0</amount>
<interest_rate>18.9</interest_rate>
<term>36</term>
</items>
<total_count>13</total_count>
</Response>


Please advise me what is the correct format and what I am doing wrong here? Thanks 

  • Hey,

     

    I just tried to set a value as you did and it worked for me.

     

    Are you sure that the property is called CLContractName?

    What version of ReadyApi do you use?

    Probably not relevant but BY-12223 doesn't exist in your sample xml.

6 Replies

  • Lucian's avatar
    Lucian
    Community Hero

    Hey,

     

    I just tried to set a value as you did and it worked for me.

     

    Are you sure that the property is called CLContractName?

    What version of ReadyApi do you use?

    Probably not relevant but BY-12223 doesn't exist in your sample xml.

    • mpw83's avatar
      mpw83
      Contributor

      Lucian  Thanks. The mentioned way is the correct way to set the property value. After the investigation, I found that I am getting null because the test case property value is empty otherwise its correct

          //*:e[*:name = '${#TestCase#CLContractName}']/*:id

       

      • Lucian's avatar
        Lucian
        Community Hero

        Well it's nice that you figured it out. :D

    • TanyaYatskovska's avatar
      TanyaYatskovska
      SmartBear Alumni (Retired)

      Hi mpw83,

      Could you please let us know if you still need assistance on this question?