listvariablesrobotframework

Value of variable '@{credentials}[0]' is not list or list-like


I am an new robotframework user, when I try to use list variable, I got below error. Really don't where am I wrong?

Value of variable '@{credentials}[0]' is not list or list-like.

@{credentials}    Admin    admin123
Input Text    id=txtUsername    @{credentials}[0]

Solution

  • Before Robot Framework 3.1, the format to access list items was @{credentials}[0]. In current version, the format is ${credentials}[0].

    Format @{credentials}[0] can only be used on a list of lists (meaning the final result is a list).

    Declare and then call your list variable as follows:

    @{credentials}    Admin    admin123
    Input Text    id=txtUsername    ${credentials}[0]
    

    See the documentation: Accessing list and dictionary items