Search code examples
variablesrobotframework

issue with loging a list and list element in robot frame work


i want to log a list in robot frame work

i tried LOG @{listname} but it throws an error

to acccess the list element i use LOG @{listname}[0] it also throws an error

LOG @{listname} -- print list to log LOG @{listname}[0] -- print the first element to log


Solution

  • Reference: https://robotframework.org/robotframework/latest/libraries/Collections.html#Log%20List There is Log List to log all the values in List. Please see the below example

    *** Settings ***
    Library    Collections
    
    *** Variables ***
    @{NUMBERS}       ${1}    ${2}    ${5}
    @{NAMES}         one     two     five
    *** Test Cases ***
    Logs Lists
        Log List    ${NUMBERS}
    
    Log Scalar Variable
        Log    ${NUMBERS}[0]