简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM