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

Viewed 2008

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]
3 Answers
  • '@{credentials}[0]' is not list or list-like.

    @{credentials} Admin admin123 Input Text id=txtUsername
    @{credentials}[0]
    This is a list in robot framework to extract Admin we can use ${credentials}[0] you get the error because your framework version is higher but you refer to the old content. for Mr, it is resolved by using this ${credentials}[0] . for more clarity, you can refer to this https://robocorp.com/docs/languages-and-frameworks/robot-framework/variables

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).

See the documentation: Accessing list and dictionary items

Please Check your code format is right in your question. But I guess your code is like below:

*** Variables ***
    @{credentials}    Admin    admin123

*** Test Cases ***
    Create List Variable
    Log    @{credentials}[0]

If you want to input Admin to id-txtUsername, You need change like this:

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

I think you need to read this section to figure out how @ sign works. With @ sign, the list is expanded and individual items.

Example from User Guide. Both Testcase is the same:

*** Test Cases ***
Constants
    Login    robot    secret

List Variable
    Login    @{USER}
Related