cancel
Showing results for 
Search instead for 
Did you mean: 

How to compare values from two array

Highlighted
Occasional Contributor

How to compare values from two array

ask.pngplease tell how to compare the below two result sets. If true, then print, price are same.

 

@nmraosir @HimanshuTayal sir please enlighten

8 REPLIES 8
Highlighted
Community Hero

Re: How to compare values from two array

def list1 = [1299, 3099]
def list2 = [1299.0, 3099.0]
assert list1 == list2, 'both lists are not matching'

Have you tried as above?



Regards,
Rao.
Highlighted
Community Leader

Re: How to compare values from two array

@_lauren11 : 

 

There are various ways to compare array. You can refer below link.

 

compare list 

 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Highlighted
Occasional Contributor

Re: How to compare values from two array

i tried this too.. but it's giving error. It says, "java.lang.AssertionError: both list are not matching"

Highlighted
Community Hero

Re: How to compare values from two array

Have you tried exactly above code and you getting the assertion fail? Only getting error for your data only?
May be you want to provide your both samples of XML data.


Regards,
Rao.
Highlighted
Occasional Contributor

Re: How to compare values from two array

Sir, i then converted list 1 response into decimal form. And then applied assert, which is now working

Highlighted
Community Leader

Re: How to compare values from two array

@_lauren11 : As i can see in your question's screenshot, you are converting into String, so try to covert into List.

 

Hope this will work.


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Highlighted
Community Hero

Re: How to compare values from two array

what happened to this? No update after the replies to the issue?


Regards,
Rao.
Highlighted
Occasional Contributor

Re: How to compare values from two array

I replied in my previous comment that, i then converted list 1 response into decimal form., as list 2 was already in decimal kind of notation. After that, I applied assert. 🙂

 

Regards..!

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