XPath extractor is post processor component of JMeter. XPath extractor extracts text from the HTML response based on XPath query provided.
To use XPath extractor in the Test plan we need to add it as a child element of HTTP Request sampler.
Example to use XPath Extractor in JMeter Test plan
Step 1: Add Thread Group to the Test plan and configure as shown below
Step 2: Add HTTP Request sampler to the Test plan and configure it as shown in below image.
Step 3: Add Xpath Extractor post processor as child element of HTTP request sampler
Step 4: Configure the newly added XPath Extractor as shown below
Step 5: Add Beanshell post processor as child element of HTTP request sampler. It will help to display the xpath value to the console
Fields in XPath Extractor
Name: User can give any convenient name to the XPath extractor.
Name of created variable: Result will be stored in this variable.
XPath query: User can mention the xpath query. It can return more than one match.
Match No: If XPath query returns more than one match then user needs to specify required match no.
Default Value: If no match is found by the XPath query then default value is used.
Return entire XPath fragment instead of text content?: If unchecked then XPath query returns only the text value which is matched. If checked then XPath query returns entire XPath fragment.
If ‘Return entire XPath fragment instead of text content?’ is checked then following output is seen
If ‘Return entire XPath fragment instead of text content?’ is unchecked then following output is seen