As i've mentioned in my earlier posts about how assertions can be of help in validating the right response code
Xpath Assertion eases life when we have to validate if an object exists.
Let's again take a shopping cart example.
1.Search for an item
2.Add selected item to shopping cart > now we want to verify if the Add cart button is available on the page.
Therefore we need to add a xpath assertion.
Below screen shot should give a clear idea & how an expression is built.
Let's have a closer look at the Xpath Assertion.
Add a xpath Assertion :
1. Right Click on the HTTP Sampler > Assertions > Xpath Assertions.
Once you'ev added the Xpath Assertion, now we have to add appropriate values so that we can assert object or value.
1. Give a name to Xpath Assertion just like i have given not necessarily same.
2. XML Parsing Options - Check the Checkbox's against "Use Tidy(tolerant parser) & Quiet".
3. Xpath Assertion - contract the xpath & pass the xpath string within the Xpath Assertion.
For ex : I am validating to see if the button with id "bestAvailableTickets_LookForTicketsButton"" exists on that page.
I have left the "True if nothing matches" as unchecked as i want it to match.