Is there any custom method which can check if a json node is present?
I have a json like this
Blockquote
{
“body”: {
“user”: {
“surname”: “Morris”,
“firstName”: “James”,
“dateOfBirth”: “1983-04-19”,
“titleCode”: “Mr”,
“middleName”: “P”,
“genderCode”: “male”
}
}
}
Blockquote
I do see method like
WS.verifyElementPropertyValue(response, 'body.user.firstName', "James")
WS.verifyElementsCount(response, 'body.user', 6)
which are fine. Is there any method to check if a specific node is present using katalon inbuild method, something like
WS.verifyNodePresent(response, 'body.user.firstName', true)
WS.verifyElementsCount(response, 'body.user.firstName', 1)
hello,
i assume response is already an json object in that case:
response.body.user.surname != null
will check if node is there with any value.
for more complex checks use something like
Thank you Andrej
Currently i am using something like that with the assert statement. I hope if Katalon can expose some api’s like i suggested, code will be more consistent. Or else i will end up with some custom methods and some katalon specific methods. The reason for choosing Katalon is the rich set of API’s they provide. I am sure this will be the requirement for most of the teams which verify the json body.
So before using something like
WS.verifyElementPropertyValue(response, 'body.user.firstName', "James")
I will check if the node is present or not.
but response can be anything from pure text to xml/html json … this heavily depends on application.
just in case try to formulate request and put it in to feature request forum.