четвртак, 17. април 2014.

XPath Extraction in JMeter


Using the XPath Extractor in JMeter

 

In practice, we usually need to send as parameter value we retrieved in previous response. We can extract value from response using Xpath Extraction.


  1. Right click on SOAP/XML-RPC Request.  
  2. Add – Post Processors – Xpath Extractor
  3. Fill fields as it is shown on the picture.


понедељак, 14. април 2014.

How to extract value from response when response is sometimes null

During the testing, I had the next issue. I need to extract name from response. However, for some valuse of input parameters (language), response was null because there were not name in database for some languages. In that case, it was not possible to do xpath extraction from null response and test fail.

I solved it on the next way. I Sent request without any extraction. In the next step (shown bellow) I got size of response. Further, using IF controller I checked if data_length is bigger than 0 and I sent again request, this time with xpath extraction.

response = prev.getResponseDataAsString();
data_length = new Integer(response.length());
vars.put("data_length", data_length.toString());

if(data_length == 0)
{
vars.put("name", "NOT_FOUND");
}