Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

Dictionaries Should Be Equal Robot Framework

Dictionaries Should Be Equal keyword is used to compare dictionaries. If they are not equal, the keyword will Fail. See the implementation below. 

 

*** Settings ***
Library           Collections

*** Test Cases ***
Dictionaries Should Be Equal Test
    Comment    Fails if the given dictionaries are not equal.
    ${Dict1}=    Create Dictionary
    Set To Dictionary    ${Dict1}    Foo1    Value1
    Set To Dictionary    ${Dict1}    Foo2    Value2
    Log Dictionary    ${Dict1}
    ${Dict2}=    Create Dictionary
    Set To Dictionary    ${Dict2}    Foo1    Value1
    Set To Dictionary    ${Dict2}    Foo2    Value2
    Log Dictionary    ${Dict2}
    Dictionaries Should Be Equal    ${Dict1}    ${Dict2}

Run the test and observe the result. The test passed.

Starting test: RobotCollectionsExample.Collections Keyword Test Suite.Dictionaries Should Be Equal Test
20150426 08:15:02.351 :  INFO : ${Dict1} = {}
20150426 08:15:02.351 :  INFO : 
Dictionary size is 2 and it contains following items:
Foo1: Value1
Foo2: Value2
20150426 08:15:02.351 :  INFO : ${Dict2} = {}
20150426 08:15:02.351 :  INFO : 
Dictionary size is 2 and it contains following items:
Foo1: Value1
Foo2: Value2
Ending test:   RobotCollectionsExample.Collections Keyword Test Suite.Dictionaries Should Be Equal Test