What are the SOAP UI XPath Assertions?
With the help of Xpath, we can traverse to the particular node in the XML.
Ex. –
XPATH is like a delivery address. Assuming age, department, id, and name are 4 homes in the city called XML. If you want to go to each and every home you need correct unique address Xpath [Unique address of that node].
The same way we have to write unique Xpath to reach that node and then we can extract value from it.
In the below screen age is one node, id is another node.
The same way we have to write unique Xpath to reach that node and then we can extract value from it.
In the below screen age is one node, id is another node.
Let see how we can add the XPath assertions:
Step1:
Go to Add Assertion > Property Content > Xpath Match.
Click on the Declare button.
Start writing XPath from the root nodes.
At last click on the Select From current > Test link to validate the response.
Some pre defines functions to find the XPath:
exists –
By using exists function, we can check whether the tag is present in the response or not.
We write true/false value in it to check the existence.
Steps1:
Go to Add Assertion > Property Content > Xpath Match.
Click on the Declare button.
Start writing XPath from the root nodes and use the exists method.
At last click on the Select From current > Test link to validate the response.
Count:
By using Count function we will check the number of counts present in the response.
Suppose if we want to get all the notes present in the XPath Match then:
Write Parent node > Select From current > Test
In some cases, suppose id value is getting change continuously, in that case, we will write * in place of id and we will click on checkbox ‘Allow Wildcards’.
Interview Questions from this Page:
a. Suppose id is kept on changing then how you will handle.
b. How we can use Xpath functions.







No comments:
Post a Comment