bennythedroid
15 years agoOccasional Contributor
Script Assertions to verify XPath Value
I have a test that generates a new id every time I POST. I only get a header and the location for the POST response.
For example:
Run the test, the location is: http://aaa.bbb.message.com/Service/rest/broadcasts/3097
I run it again, and the location for the new id is: http://aaa.bbb.message.com/Service/rest/broadcasts/3098
So, it's sequential, with each new id the prior number +1 (so 3097, 3098, 3099, etc)
Within that id is xml content, for example:
<Response xmlns="http://aaa.bbb.message.com/Service/rest/broadcasts/3097">
<prepare>false</prepare>
<send>false</send>
<messageId>62698db6-0234-4138-8375-992566aa7086</messageId>
<containerId>42bc0fba-e94a-4d9b-8f68-61c821620531</containerId>
<id>3097</id>
<listId>634cd0ed-4eb6-480d-aefe-7cf712aa6e4d</listId>
<status>
<overallState>CREATED</overallState>
</status>
</Response>
The user case I am testing is that I am posting two different bodies, lets call them A and B, which I store in a Properties test step. The POST I am making should use the containerId in the XML for A, and not B to create it's own entity.
I would like to, in a script, assert that the containerId within that XML for my new POST equals the containerId for A, and not B.
I tried doing this in a XPath Match assertion, but I can't figure out how to get the namespace to automatically update with the sequential ids (3097, 3098, 3099). The service I am using will not let me delete the ids, so I can't just delete and the POST the repeat id.
I need some help with the code/syntax to do it in a script. I think this is my best option.
For example:
Run the test, the location is: http://aaa.bbb.message.com/Service/rest/broadcasts/3097
I run it again, and the location for the new id is: http://aaa.bbb.message.com/Service/rest/broadcasts/3098
So, it's sequential, with each new id the prior number +1 (so 3097, 3098, 3099, etc)
Within that id is xml content, for example:
<Response xmlns="http://aaa.bbb.message.com/Service/rest/broadcasts/3097">
<prepare>false</prepare>
<send>false</send>
<messageId>62698db6-0234-4138-8375-992566aa7086</messageId>
<containerId>42bc0fba-e94a-4d9b-8f68-61c821620531</containerId>
<id>3097</id>
<listId>634cd0ed-4eb6-480d-aefe-7cf712aa6e4d</listId>
<status>
<overallState>CREATED</overallState>
</status>
</Response>
The user case I am testing is that I am posting two different bodies, lets call them A and B, which I store in a Properties test step. The POST I am making should use the containerId in the XML for A, and not B to create it's own entity.
I would like to, in a script, assert that the containerId within that XML for my new POST equals the containerId for A, and not B.
I tried doing this in a XPath Match assertion, but I can't figure out how to get the namespace to automatically update with the sequential ids (3097, 3098, 3099). The service I am using will not let me delete the ids, so I can't just delete and the POST the repeat id.
I need some help with the code/syntax to do it in a script. I think this is my best option.