Comparing two lists in robot framework

916 views
Skip to first unread message

sreeramoju pranithkumar

unread,
Apr 4, 2022, 8:58:35 AM4/4/22
to robotframework-users
${Record_Details_DB}:

[{'Date': ['2022-03-04'], 'Uetr': ['37b63ffdbff5-W7394ss-fdef992'], 'EndToEndID': '[]', 'MessageReference': ['object123'], 'SwiftMsgType': ['Pacs.008'], 'SenderBIC': ['3YHBXDNF2BX'], 'ReceiverBIC': ['3RBCLOGINPA'], 'DebtorName': ['inheritance'], 'CreditorName': ['polymorphism'], 'DebtorAccount': ['12345678912345678912345678912345678'], 'Currency': ['GBP'], 'Amount': [990.0], 'PaymentStatus': '[]'}, {'Date': ['2022-03-04'], 'Uetr': ['37b63ffdbff5dd-W7394ss-fdef992'], 'EndToEndID': '[]', 'MessageReference': ['object123'], 'SwiftMsgType': ['Pacs.008'], 'SenderBIC': ['3YHBXDNF2BX'], 'ReceiverBIC': ['3RBCLOGINPA'], 'DebtorName': ['objectoriented'], 'CreditorName': ['programming'], 'DebtorAccount': ['12345678912345678912345678912345678'], 'Currency': ['INR'], 'Amount': [990.0], 'PaymentStatus': '[]'}, {'Date': ['2022-03-03'], 'Uetr': ['37b63dbff5-W7394ss-fdef992'], 'EndToEndID': '[]', 'MessageReference': ['object123'], 'SwiftMsgType': ['Pacs.008'], 'SenderBIC': ['3YHBXDNF2BX'], 'ReceiverBIC': ['3RBCLOGINPA'], 'DebtorName': ['Test123'], 'CreditorName': ['dynamic123'], 'DebtorAccount': ['12345678912345678912345678912345678'], 'Currency': ['GBP'], 'Amount': [125.95], 'PaymentStatus': '[]'}]

${Record_Details_UI}


["{'Date':[2022-03-04]", "'Uetr':[37b63ffdbff5-W7394ss-fdef992]", "'EndToEndID':[]", "'MessageReference':[object123]", "'SwiftMsgType':[Pacs.008]", "'SenderBIC':[3YHBXDNF2BX]", "'ReceiverBIC':[3RBCLOGINPA]", "'DebtorName':[inheritance]", "'CreditorName':[polymorphism]", "'DebtorAccount':[12345678912345678912345678912345678]", "'Currency':[GBP]", "'Amount':[990]", "'PaymentStatus':[]}", "{'Date':[2022-03-04]", "'Uetr':[37b63ffdbff5dd-W7394ss-fdef992]", "'EndToEndID':[]", "'MessageReference':[object123]", "'SwiftMsgType':[Pacs.008]", "'SenderBIC':[3YHBXDNF2BX]", "'ReceiverBIC':[3RBCLOGINPA]", "'DebtorName':[objectoriented]", "'CreditorName':[programming]", "'DebtorAccount':[12345678912345678912345678912345678]", "'Currency':[INR]", "'Amount':[990]", "'PaymentStatus':[]}", "{'Date':[2022-03-03]", "'Uetr':[37b63dbff5-W7394ss-fdef992]", "'EndToEndID':[]", "'MessageReference':[object123]", "'SwiftMsgType':[Pacs.008]", "'SenderBIC':[3YHBXDNF2BX]", "'ReceiverBIC':[3RBCLOGINPA]", "'DebtorName':[Test123]", "'CreditorName':[dynamic123]", "'DebtorAccount':[12345678912345678912345678912345678]", "'Currency':[GBP]", "'Amount':[125.95]", "'PaymentStatus':[]}"]

To Compare two lists, I have written the code as below. 

FOR ${i} IN @{Record_Details_DB}
log ${i}
List Should Contain Sub List ${Record_Details_UI} ${i}
END

But I am getting below error. 
Following values were not found from first list: Date, Uetr, EndToEndID, MessageReference, SwiftMsgType, SenderBIC, ReceiverBIC, DebtorName, CreditorName, DebtorAccount, Currency, Amount, PaymentStatus

Any help regarding the above issues will be highly appreciated. 

Craig Despeaux

unread,
Apr 4, 2022, 12:51:13 PM4/4/22
to robotframework-users
${i} isn't a list - it's a dictionary.  I think you want to use iterate through one of the lists and use List Should Contain Value against the other to verify it contains the same dictionary.  You may also want to follow that up with Lists Should Be Equal or at least verify that they are the same size.  I'm a little rusty since I haven't used robot for 4 months, but I think my analysis is correct.

Craig 

Reply all
Reply to author
Forward
0 new messages