Skip to content

List not passed as a list using embedded argument. #2705

Closed

Description

@djaromir

I have encountered problem when passing a list as embedded argument. Here is the example:

*** Settings ***
Documentation    Problematic Suite

*** Variables ***
${condition}    0

*** Keywords ***
Log My List ${MyList}
    Log Many   @{MyList}

*** Test Cases ***
LD_0: Pass List in If Statement.
    [Documentation]    Problem example.
    [Tags]    Problem
    @{LIST}=    Create List    item1    item2    item3
    Log My List ${LIST}
    Run Keyword If  ${condition} == 0    Log My List ${LIST}

First usage of Log My List keyword is fine, logs the list perfectly. Second usage, in if statement keeps telling me:

Value of variable '@{MyList}' is not list or list-like

Solved by using traditional arguments
https://stackoverflow.com/questions/47094323/robot-framework-how-can-i-pass-a-list-to-a-keyword-in-an-if-statement/47094702#47094702

Activity

  1. pekkaklarck commented on Nov 3, 2017

    @pekkaklarck
    Member

    This is actually a know problem documented by #1595. Fixing it in generic manner so that all objects could be passed like this would be really hard, but we could actually workaround it when using lists or dictionaries pretty easily.

    We already have #2699 about supporting @{list} and &{dict} variables with embedded arguments. We could implement that so, that if we have a keyword like

    *** Keywords ***
    Example @{args}
        Log Many    @{args}

    and it is used like Example ['foo', 'bar', 'zap'], the framework converts the string ['foo', 'bar', 'zap'] into a matching list. The main downside would be that you'd normally rather use syntax like Example foo, bar, zap instead. Perhaps we could support both?

  2. djaromir commented on Nov 3, 2017

    @djaromir
    Author

    Too bad the issue was discovered in 2013 originally :( If Robot Framework could support both described syntax that would be perfect.

  3. pekkaklarck commented on Nov 3, 2017

    @pekkaklarck
    Member

    Yeah, this is an old issue but it occurs so seldom and generic fix would be so hard that nobody has bothered to do anything to it. I'll close this as a duplicate of #1595. Let's see would #2699 provide a workaround for lists and dicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions