Ask a Question

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

SOLVED
mpw83
Contributor

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 

6 REPLIES 6
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.



If my answer helped please click on the 'Accept as Solution' button.
TanyaYatskovska
SmartBear Alumni (Retired)

Hi @mpw83,

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

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



@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

 

@TanyaYatskovska Thanks, I don't need any further help regarding this issue . 

TanyaYatskovska
SmartBear Alumni (Retired)

Happy to hear that the issue was resolved, @mpw83  🙂

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



Lucian
Community Hero

Well it's nice that you figured it out. 😄



If my answer helped please click on the 'Accept as Solution' button.
cancel
Showing results for 
Search instead for 
Did you mean: