Assertions: check that number of response is bigger then 10
Could someone tell me how I could add an XPath that says:
Response contains > 10 answers, not knowing what the answers are but one is expecting more then 10?
Thanks in advance,
Solved! Go to Solution.
That was a request, not a demand. Sorry if it feels so.
What kind of assertion you tried? And what was the result?
I think my English is not so good. And I think neather are the translaters. It was just a translation from dutch to english. Sorry for that. A demand in dutch is "a question for" or " a question from". You too, please, don't take this personal! 😉
I do understand that you would have more quick answers if I gave more content explanation but I actually can't understand why you need a context. Maybe because there are different XPath assertions for this question? I just thought that there was a default notation for this. But ok:
TestCase: Test if you find a company with Name
TestStep: 1) full name ==> only 1 company will be shown
2) partial name (minimum 4 chars) ==> more then 10 names are expected
For second teststep I would like an assertion knowing that the answer will be in json and that I don't have had an answer yet, because we don't have a stable environment yet. I know that this sound weird, because as tester you should have an environment before you can test anything, but the client wants me to 'prepare' everything meanwhile and finetune in the futur where necessary.
Thanks in advance to give it a try.
Hi @AAB ,
Do you need the expression for JSON or XML?
If you need it for JSON, there is the JsonPath Count assertion:
I've converted the provided response to XML (attached). In the XPath you can use the count() function.
For the provided XML, the expression will be:
Please check the screenshot:
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Thank you @Nastya_Khovrina
For the moment our mock environment is down. I'm also awaiting our test environment for next week. If one of them is up I will see if this works. But I'm practically sure.
So please be patient with me before I can accept this as a solution.
The json count assertion works only for a specific value - you can't specify any maths operators like >, < to say that a node has >10 records in there - this was the first thing I checked when I saw your post.
HOWEVER - the XPATH which @Nastya_Khovrina has provided IS what you need - right?
I did try and view the .xml you attached to identify the repeating groups so I could give you the specific XPATH relative to your file - however - I couldn't see any repeating groups when I viewed the file?!?!?!?!?!.
Yes indeed, there are only companies present 1 time. It's enough to copy them several times in the file. 😉 I didn't thought about that.
thanks for your explanation!
Concerning if it works or not: I still need to wait my environment access. I'll let you know 😉
For my environment apparently it's a little bit different. I do receive a JSON response but your notation doesn't give me the proper assertion. I could use the 'point and click' action in ReadyAPI that gives me this:
Thanks for your help though!