Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

Append To List Robot Framework

In Robot Framework, the keyword "Append To List" is used to add values to the end of list.  See the example below. 

*** Settings ***
Library           Collections

*** Test Cases ***
Append To List Test
    [Documentation]    Adds values to the end of list
    @{MyList}=    Create List
    Append To List    ${MyList}    a
    Append To List    ${MyList}    b
    Append To List    ${MyList}    c
    Append To List    ${MyList}    d
    Append To List    ${MyList}    abcd
    Log List    ${MyList}
    List Should Contain Value    ${MyList}    abcd
 

Run the script and see the result below

Starting test: RobotCollectionsExample.Collections Keyword Test Suite.Append To List Test
20150416 23:25:28.476 :  INFO : @{MyList} = [ ]
20150416 23:25:28.476 :  INFO : 
List length is 5 and it contains following items:
0: a
1: b
2: c
3: d
4: abcd
Ending test:   RobotCollectionsExample.Collections Keyword Test Suite.Append To List Test

The result shows that a, b, c, d, and abcd are added to the list ${MyList}