Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

SOATest: Use of datasource column names in the XPath editor

Testuser
Testuser Posts: 41

I have the below JSON response where I need to assert the statusCode for a particular name and this name is getting fetched from the 'name' column in the excel sheet used as a datasource.

JSON response:
[
{
"clientTypeCode": "IP",
"statusCode": "PEND",
"statusName": "Pending Approval",
"id": 0,
"name": "test1"
},
{
"clientTypeCode": "IP",
"statusCode": "PEND",
"statusName": "Submitted",
"id": 0,
"name": "test2"
}
]
For this one when I used a JSON Assertor and added a Value Assertion for the statusCode element and using XPath changed the element to as below:
/root/item[name='test1']/statusCode/text()
Clicked on Evaluate XPath and it showed the right status in the Result section.
But my question is-Is there a way I can change the above XPath query to use the column name ('name') from the excelsheet(datasource) instead of using 'test1'.
For ex something like as below:
/root/item[name=${name}']/statusCode/text()

Any help is much appreciated!
Thanks!

Tagged:

Best Answers

Answers

  • Testuser
    Testuser Posts: 41

    Some more information:
    I've tried parameterizing the Xpath using the data source column but when I evaluate Xpath it shows "No nodes found". I am using SOATEST 9.9.
    /root/item[name=${name}']/statusCode/text()

  • Thomas Moore
    Thomas Moore Posts: 82 admin

    Additionally, the XPATH you are showing here in chat is malformed, as there is a singular ' after ${name} that might be causing your issue.

    Can you try using:
    /root/item[name=${name}]/statusCode/text()?

  • Testuser
    Testuser Posts: 41

    Thanks Thomas and jakubiak. Sorry for the missing single quote in my Xpath expression. I've used below Xpath and for all of them it says "No nodes found":
    /root/item[name="${name}"]/statusCode/text()
    /root/item[name='${name}']/statusCode/text()
    So I ran this time and during runtime it did run fine. So looks like Evaluate button in Xpath editor doesn't show the right results always.