Print

Dictionary Should Contain Value Robot Framework

Dictionary Should Contain Value keyword is used to check if a dictionary contains a value. If value is not found, the keyword Fail. See the implementation below. 

 

*** Settings ***
Library           Collections

*** Test Cases ***
Dictionary Should Contain Value Test
    Comment    Fails if value is not found from dictionary
    ${MyDict}=    Create Dictionary    Foo1    Value1
    Set To Dictionary    ${MyDict}    Foo2    Value2
    Log Dictionary    ${MyDict}
    Dictionary Should Contain Value    ${MyDict}    Value2
    Comment    You can use keyword Dictionary Should Not Contain Value in similar ways

Run the script above. The test passed. 

Starting test: RobotCollectionsExample.Collections Keyword Test Suite.Dictionary Should Contain Value Test
20150426 08:26:50.078 :  INFO : ${MyDict} = {u'Foo1': u'Value1'}
20150426 08:26:50.078 :  INFO : 
Dictionary size is 2 and it contains following items:
Foo1: Value1
Foo2: Value2
Ending test:   RobotCollectionsExample.Collections Keyword Test Suite.Dictionary Should Contain Value Test