Ask a Question

Assertions: check that number of response is bigger then 10

SOLVED
AAB
Regular Contributor

Assertions: check that number of response is bigger then 10

Hi,

 

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,

Kind regards,

AboveAndBeyond

9 REPLIES 9
nmrao
Champion Level 2

Would be helpful with sample data.


Regards,
Rao.
AAB
Regular Contributor

on demand of @nmrao 

 

See attached

 

 

nmrao
Champion Level 2

Always context, data (even sample would do) to the problem are important to understand better and quick.

That was a request, not a demand. Sorry if it feels so.

What kind of assertion you tried? And what was the result?


Regards,
Rao.
AAB
Regular Contributor

Rao

 

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.

Kind regards,

AboveAndBeyond

 

Nastya_Khovrina
SmartBear Alumni (Retired)

Hi @AAB ,

 

Do you need the expression for JSON or XML?

 

If you need it for JSON, there is the JsonPath Count assertion:

2019-03-14_17-58-50.png

 

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:

count(//root[1]/element[*])>10

Please check the screenshot:

2019-03-14_18-00-53.png


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
AAB
Regular Contributor

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.

 

Thanks,

Kind regards,

AboveAndBeyond.

richie
Community Hero

Hey @AAB

ah - when I responded I hadn't seen @Nastya_Khovrina's response.

 

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?!?!?!?!?!.

 

Cheers,

 

richie

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
AAB
Regular Contributor

@richie 

Hey Richie,

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  😉

 

Cheers,

AboveAndBeyond.

AAB
Regular Contributor

@Nastya_Khovrina 

Hi Nastya,

 

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:

 

JSONxpath.png

 

Thanks for your help though!

 

Kind regards,

AboveAndBeyond.

cancel
Showing results for 
Search instead for 
Did you mean: