Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

Copy List Robot Framework

Copy List keyword returns a copy of the given list. See the example below. 

 

*** Settings ***
Library           Collections

*** Test Cases ***
Copy List Test
    comment    Returns a copy of the given list
    @{MyList}=    Create List    Foo1    Foo2    Foo3
    Log List    ${MyList}
    @{CopiedList}=    Copy List    ${MyList}
    Log List    ${CopiedList}
    List Should Contain Value    ${CopiedList}    Foo3

Run the script and see the result below.

Starting test: RobotCollectionsExample.Collections Keyword Test Suite.Copy List Test
20150424 00:07:37.103 :  INFO : @{MyList} = [ Foo1 | Foo2 | Foo3 ]
20150424 00:07:37.103 :  INFO : 
List length is 3 and it contains following items:
0: Foo1
1: Foo2
2: Foo3
20150424 00:07:37.103 :  INFO : @{CopiedList} = [ Foo1 | Foo2 | Foo3 ]
20150424 00:07:37.103 :  INFO : 
List length is 3 and it contains following items:
0: Foo1
1: Foo2
2: Foo3
Ending test:   RobotCollectionsExample.Collections Keyword Test Suite.Copy List Test