понедељак, 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");
}



Нема коментара:

Постави коментар