0

I have got some data from DB in List of List format which i am comparing with the Table displayed in UI. I Extracted UI Tables data into List of List and comparing DB vs UI. Here is the result.

KEYWORD Collections . Lists Should Be Equal ${DataFromDB}, ${DataFromUI}
Documentation:  
Fails if given lists are unequal.

Start / End / Elapsed:  20180306 22:33:28.245 / 20180306 22:33:28.245 / 00:00:00.000
22:33:28.245    FAIL    Lists are different:
Index 0: ('3/6/2018', '16', '8', '50.00', '3024', '841', '27.81') != [u'3/6/2018', u'16', u'8', u'50.00', u'3024', u'841', u'27.81']
Index 1: ('3/5/2018', '16', '9', '56.25', '3024', '2114', '69.91') != [u'3/5/2018', u'16', u'9', u'56.25', u'3024', u'2114', u'69.91']
Index 2: ('3/4/2018', '16', '9', '56.25', '3024', '2224', '73.54') != [u'3/4/2018', u'16', u'9', u'56.25', u'3024', u'2224', u'73.54']
Index 3: ('3/3/2018', '16', '9', '56.25', '3024', '2132', '70.5') != [u'3/3/2018', u'16', u'9', u'56.25', u'3024', u'2132', u'70.50']
Index 4: ('3/2/2018', '16', '9', '56.25', '3024', '2112', '69.84') != [u'3/2/2018', u'16', u'9', u'56.25', u'3024', u'2112', u'69.84']
Index 5: ('3/1/2018', '16', '9', '56.25', '3024', '2112', '69.84') != [u'3/1/2018', u'16', u'9', u'56.25', u'3024', u'2112', u'69.84']
Index 6: ('2/28/2018', '16', '9', '56.25', '3024', '2112', '69.84') != [u'2/28/2018', u'16', u'9', u'56.25', u'3024', u'2112', u'69.84']
Index 7: ('2/27/2018', '16', '9', '56.25', '3024', '2112', '69.84') != [u'2/27/2018', u'16', u'9', u'56.25', u'3024', u'2112', u'69.84']

Though Values are same. But List should Be Equal function is failing..

Not sure if this is due to because of letter 'u' in the list from UI.

Can any one tell what could have went wrong.?

Edit:

Also from RF doc {For example, Python tuple and list with same content are considered equal.} not sure why "Lists Should Be Equal" Keyword failing

Psytho
  • 3,313
  • 2
  • 19
  • 27
bbk
  • 229
  • 1
  • 6
  • 17

1 Answers1

1

You are comparing tuple to a list. Change your first () to [] and it would work.

a = ['3/6/2018', '16', '8', '50.00', '3024', '841', '27.81']
b = [u'3/6/2018', u'16', u'8', u'50.00', u'3024', u'841', u'27.81']
a1 = ('3/6/2018', '16', '8', '50.00', '3024', '841', '27.81')
print('List to list: ',a == b)
print('Tuple to list:',a1 == b) #your current tuple to list comparison  

Output:

List to list:  True
Tuple to list: False

Note

how to convert tuple to list

If this ('3/6/2018', '16', '8', '50.00', '3024', '841', '27.81') is your entry, then just pass it to list() function - it will take care of it. Here are more examples.

Anthony
  • 421
  • 1
  • 5
  • 13
  • thanks @Anthony. Could you pl suggest a solution (converting from Tuple to list) to my tuple data. – bbk Mar 07 '18 at 01:41
  • Also jus read from RF doc {For example, Python tuple and list with same content are considered equal.} not sure why "Lists Should Be Equal" Keyword failing – bbk Mar 07 '18 at 02:11
  • I've added a note to your question – Anthony Mar 07 '18 at 02:13
  • @bbk, "not sure why "Lists Should Be Equal" " - you can try to compare to lists with the same content and, after, change some value in one list or another, the result will be different. – Anthony Mar 07 '18 at 02:19