Theodoros Chatzigiannakis
Theodoros Chatzigiannakis

Reputation: 29213

Is it possible to declare a keyword with arguments inside the name?

I want to declare a keyword in the following format:

Environment variable    SOME_DIR   is   C:\\Something

I've tried doing it via this decorator:

@keyword(name = "Environment variable ${name} is ${value}")
def setEnvVar(self, name, value):
    # ...

But it is not recognized when I try to call it:

No keyword with name 'Environment variable' found.

Is this syntax possible in Robot Framework? If so, how?

Upvotes: 1

Views: 206

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385970

The way you're defining the keyword is correct. The way you are calling it in your test is not.

When you use two or more spaces between items in a statement, robot uses that to determine the keyword name and arguments. Thus, when you do Environment variable SOME_DIR is C:\\Something, it see it as the keyword Environment variable followed by the arguments SOME_DIR, is, and C:\\Something.

Since you are using embedded arguments, you can't use multiple spaces. You need to call the keyword like this:

environment variable SOME_DIR is c:\\Something

For more information see Embedding arguments into keyword names in the robot framework user guide.

Upvotes: 3

Related Questions