Satheesh Satheesh - 3 months ago 14
JSON Question

How to handle assertion property content for differenrt responses?

I would like to handle assertion property content according to below responses, for both success and failure.

Success response:

{
"task": "userLogin",
"response": {
"code": 0,
"status": "success",
"error_message": "",
"success_message": "",
"data": {
"userId": "65",
"username": "indian",
"email": "test@gmail.com",
"token": "b0aef6139ffdc1041e01f7587a0dcf61",
"userType": "trial",
"profile_picture": "test.png"
}
}
}


Failure response: will have only the
data
node missing, and remaining nodes will be present.

"data":
{
"userId": "65",
"username": "indian",
"email": "test@gmail.com",
"token": "b0aef6139ffdc1041e01f7587a0dcf61",
"userType": "trial",
"profile_picture": "test.png"
}

Answer

You can use a very simple XPath assertion, keeping in mind that internally SoapUI converts everything into XML representation.

XPath:

exists(//*:data)

Expected:

true
Comments