Skip to content

Syntax consistency issue between variables in keywords and variables inside variables #5486

@Symeon94

Description

@Symeon94

I have noticed some small inconsistency in Robot Framework syntax when it comes to keywords' and variables' names.

  • The framework allows for variable inside variables like: ${my ${test} var}
  • It also allows for variable inside keywords like My ${test} keyword

Now, as the documentation specifies, spaces and underscore are ignored in keywords, meaning that Some keyword can as well be written as someKeyword or Some_Keyword, but as soon as you have a variable defined in a keyword, that is no longer the case, meaning that My ${test} keyword will not match to mySomethingKeyword because the spaces are mandatory there.

As per documentation 2.7.5:

They [keywords with embedded arguments] are also used the same way as other keywords except that spaces and underscores are not ignored in their names when keywords are matched.

Now, the problem is that there is a lack of consistency with variables. For variables too the spaces and underscore are ignored, so ${OUTPUT DIR} can be written as ${outputDir} or ${output_dir}.
If you add a variable to a variable, contrary to keywords, spaces and underscore are ignored. Taking back my ${my ${test} var} it can match ${myGreatVar} or ${my_other_var}.

I don't know if this will ever change, but I find this lack of consistency between the two kind of strange. If it was consistent we could define a keyword name syntax as <name> and a variable name syntax simply being the same name but between brackets ${<name>}.

Update: I'm using version 7.0.1. I know some changes have been introduced with 7.3 that adds typing for variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions