Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

Get Dictionary Items Robot Framework

Get Dictionary Items keyword returns the items of a given dictionary. See the example below. 

 

*** Settings ***
Library           Collections

*** Test Cases ***
Get Dictionary Items Test
    Comment    Returns items of the given dictionary
    ${dict}=    Create Dictionary
    Set To Dictionary    ${dict}    Foo1    Value1
    Set To Dictionary    ${dict}    Foo2    Value2
    ${items}=    Get Dictionary Items    ${dict}
    Log List    ${items}
    List Should Contain Value    ${items}    Value1

Run the script and see the result

Starting test: RobotCollectionsExample.Collections Keyword Test Suite.Get Dictionary Items Test
20150424 00:16:16.962 :  INFO : ${dict} = {}
20150424 00:16:16.962 :  INFO : ${items} = [u'Foo1', u'Value1', u'Foo2', u'Value2']
20150424 00:16:16.962 :  INFO : 
List length is 4 and it contains following items:
0: Foo1
1: Value1
2: Foo2
3: Value2
Ending test:   RobotCollectionsExample.Collections Keyword Test Suite.Get Dictionary Items Test