cancel
Showing results for 
Search instead for 
Did you mean: 

How to verify response content

SOLVED
Loli
Occasional Contributor

Re: How to verify response content

As I saw from my classmates projects,no one used json match and http code but instead the script assertion and groovy code for the loop.Although I did use script and http valid code for mine
richie
Community Hero

Re: How to verify response content

Hey @Loli,

Yep youll definitey need grooy for the loop (looping GUI functionlity is only available in readyapi not open source soapui), but the GUI assertions do support what you need to do)

Ok. I'll dig out the code for the loop and the assertions later once im infront of my laptop.

Ta

Rich
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
Loli
Occasional Contributor

Re: How to verify response content

Yes i tried as well but failed sadly,no clue on how to loop it

richie
Community Hero

Re: How to verify response content

Hey @Loli,

Im flat out at work, so im going to send you a link to follow that will give instructions on a way to loop

Cheers

Rich
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
richie
Community Hero

Re: How to verify response content

Hey @Loli,

Use the instructions from the following link.

I know they worked...i used them a whilr back

http://testautomationnoob.blogspot.com/2012/10/soapui-data-looping-with-groovy-script.html?m=1

Cheers,

Rich
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
Loli
Occasional Contributor

Re: How to verify response content

I have a minor of a problem.I sent my version to them which was correct and worked,but they wanted me to use groovy lists.I am currently trying to improve the code without the for loop for now.Capture.PNG

 

 

But it always pops up an error.Any clues on how to fix it?

Capture.PNG

 

richie
Community Hero

Re: How to verify response content

Hey @Loli,

Groovy lists. Have you any further info as to what is required to be listed?

In regards to the lists you specified, i can see youve specified two variables. 'username' and 'response'.

Can you reattach the responses please?

I know json includes 2 complex datatypes: objects and arrays. Arrays which are enclosed in square brackets is what you appear to have used, and arrays are lists of comma separated values (i cant see how the comma separated values map to your response data so thats why im asking for the responses again).

Im regards to objects. These can also be lists (although from my experience i always think o arrays as liats) although the values arent just comma separated. The values in objects are comma separated name/value pairs with the intra name/value separation using a colon)

Can you confirm what your 'username' and 'response' variables are supposed to represent? I can see youve got setProperty methods which create a 'Password' property using the 'userName' variable already set, HOWEVER....this variable is a list. Surely this would equate inserting the whole list of comma separated values into the 'Password' project level property?

My groovy script is NOT great. So youll need to bare with me so i can work out what youre trying to do to see if its feasible.

Are you sure you want to list of the property values in this way?

Cheers,

Rich


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
Loli
Occasional Contributor

Re: How to verify response content

You are just in time! I am on the last step but I have a major problem.The request gives you a response that contains token,expiry date,status and a result.Currently each time you run the test the token and the expire date change.I don't really know how to store it in the list type variable for the assertion.For an example I handelded the 2nd case this way :Capture.PNG

 And it works.I want to do the same with the first case where I store the parameters and then compare the lists from the groovy script.Although because it changes every time I would have to hardcode it like this : 

assert jsonSlurper.code== "Success" which they told me not to do.It is currently 3 am and I really want to finish it today if possible.

richie
Community Hero

Re: How to verify response content

Hey @Loli,

Im in the UK, so it's almost 4am for me too!

Regarding the first assertions when youre comparing against values already setup in an excel. Later on you compare against property values for comparison. Have you considered adding the #status# header values into properties so that rather than sometime comparing against the spreadsheet and other times comparing against values set in properties, have you considered adding in your statua header valuea into propertiea as well? This would make thinga more consistent.

I appreciate its a bit naff to just hardcode an assertion value in there rather than build the value to assert against from the environment itself (this is one o the major differences between manual test assertions and automated test assertions), but sometimes you cant do anything else.

Regarding the token value. This is one of those field values that are impossible to predict absolutely, (and so contradicts whats known as "The Oracle Assumption: all tests should have predictable value, otherwise you cant test it") so theres not much you can do with that, other than to assert its present, its not null, and perhaps has a specific character length value (or range).

Regarding the response date. You think you cant assert on it cos it always changes (and this is true in someways), however if the date that is returned is always current session datetime, you could create an assertion for the date field to equate to current date? Ive done this before....ive also done a regex assertion just to confirm the datetime values matches a specific format.

Ok. Thats it for now. Im sorry fella. I gotta get up in 3 hours.

Nice one

Rich
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
richie
Community Hero

Re: How to verify response content

Regariding the groovy list of values.

You could insert that list into a single property and then split each value from the list into individual values using the split() metho maybe? This would include using a list but again make things tidier if just using properties. Just a thought. Going yo bed now

Ta

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

View solution in original post

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