cancel
Showing results for 
Search instead for 
Did you mean: 

Assertions: check that number of response is bigger then 10

SOLVED
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

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Hero

Re: Assertions: check that number of response is bigger then 10

Hey @AboveAndBeyond

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 title of the post to something more descriptive? This will help people when searching for problems.
Contributor

Re: Assertions: check that number of response is bigger then 10

@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.

9 REPLIES 9
Community Hero

Re: Assertions: check that number of response is bigger then 10

Would be helpful with sample data.


Regards,
Rao.
Contributor

Re: Assertions: check that number of response is bigger then 10

on demand of @nmrao 

 

See attached

 

 

Community Hero

Re: Assertions: check that number of response is bigger then 10

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.
Contributor

Re: Assertions: check that number of response is bigger then 10

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

 

Moderator

Re: Assertions: check that number of response is bigger then 10

Hi @AboveAndBeyond ,

 

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


Anastasia
Customer Care Team


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

Highlighted
Contributor

Re: Assertions: check that number of response is bigger then 10

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.

Community Hero

Re: Assertions: check that number of response is bigger then 10

Hey @AboveAndBeyond

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 title of the post to something more descriptive? This will help people when searching for problems.
Contributor

Re: Assertions: check that number of response is bigger then 10

@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.

Contributor

Re: Assertions: check that number of response is bigger then 10

@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.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors