Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

Copy Dictionary Robot Framework

Copy Dictionary keyword returns a copy of the given dictionary. See the example below. 

 

*** Settings ***
Library           Collections

*** Test Cases ***
Copy Dictionary Test
    Comment    Returns a copy of the given dictionary
    ${MyDictionary}=    Create Dictionary
    Set To Dictionary    ${MyDictionary}    Foo1    Value1
    Set To Dictionary    ${MyDictionary}    Foo2    Value2
    ${CopiedDictionary}=    Copy Dictionary    ${MyDictionary}
    Log Dictionary    ${CopiedDictionary}
    Dictionary Should Contain Key    ${CopiedDictionary}    Foo1
 

Run the script and see the result below

Starting test: RobotCollectionsExample.Collections Keyword Test Suite.Copy Dictionary Test
20150424 00:01:50.622 :  INFO : ${MyDictionary} = {}
20150424 00:01:50.622 :  INFO : ${CopiedDictionary} = {u'Foo1': u'Value1', u'Foo2': u'Value2'}
20150424 00:01:50.622 :  INFO : 
Dictionary size is 2 and it contains following items:
Foo1: Value1
Foo2: Value2
Ending test:   RobotCollectionsExample.Collections Keyword Test Suite.Copy Dictionary Test