Table of content

Xpath Assertion in JMeter

Xpath Assertion in Jmeter tests a response of a particular request which will validate the xpath as defines, in case xpath exists in response then that Assertion is true. If that xpath does not exist then Assertion is false means fails.

XPath assertion is useful in validating the response in case unable to find the root element directly in the response or document.

The following Example Demonstrates the Extracting Xpath from the Given Link and validates the Xpath.

  • Launch JMeter, and add Thread Group to the Test Plan.
  • Next, add HTTP Request sampler to the thread Group and then enter the Server address and path.
  • In this example, I am using the given link: to extract the Xpath.
  • I am going to verify whether this logo is present in the XPath or not.
  • Once the page has been opened, right-click on the logo and then select Inspect.
  • The source page will open as below.
  • Try to copy the Xpath of the Logo and then paste it in the editor for future use.
  • Next, add XPath Assertion to the HTTP Request.(Right-click on HTTP Request-->Add-->--Assertions--Xpath Assertion).
  • Next, Enter the copied XPath inside the Xpath Assertion and select the Use Tidy(tolerant parser) option as below.
  • Now add View Result Tree and Assertion Result Listener to the Thread Group to see the Result.
  • Save and run the Thread Group. After the Execution, the request will be passed without any error.
0 results
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions