Library Custom Keyword with underscore in name and embedded param not supported

I try to define a custom keywords with embedded parameter and an underscore in the custom name but robotframwork raises an “No Keyword …” error at runtime

  • My custom keyword implementation:

    @staticmethod
    @keyword(name=‘MY_KEYWORD with param ${param1} is not supported’)
    def test(param1: str):
    print(f"This is a test for ${param1}",file= sys.stderr)

  • My robot file
    TEST Of Custom Keyword
    MY_KEYWORD with param 42 is not supported

  • My Execution

    TEST Of Custom Keyword | FAIL |
    No keyword with name ‘MY_KEYWORD with param 42 is not supported’ found. Did you mean:
    MyLib.MY KEYWORD With Param ${param1} Is Not Supported

  • Info
    If I remove the “_” => it’s work
    If I remove the embedded argument => its’s work

I try to find similar issue discussion on forums/web, I don’t find anything.

  • Context:
  • Python 3.11
  • RobotFramework 7.1

@pekkaklarck This seems weird…any ideas?

Do you have another keyword with the same name without the underscore or even with in another reference or same file, just it’s asking you did you mean this resource/library.keyword. Which looks like it can’t quite figure it out.

Feels very much importing related or possible another keyword with the same name

Hi @Espingo,

Something I only learned myself a few days ago from the slack chat is mentioned here (Keyword names) in the documentation:

Name comparison is case-insensitive, and also spaces and underscores are ignored.

This is also a similar statement in Using variables and various other areas of the documentation

So the error message seems to be telling you not to use the underscore in the keyword name:

No keyword with name ‘MY_KEYWORD with param 42 is not supported’ found. Did you mean:
MyLib.MY KEYWORD With Param ${param1} Is Not Supported

In your robot file try changing this:

TEST Of Custom Keyword
    MY_KEYWORD with param 42 is not supported

to this:

TEST Of Custom Keyword
    MY KEYWORD with param 42 is not supported

Hopefully that will work,

Dave.

Thanks damies13 for your proposition but it doesn’t work too if I replace “MY_KEYWORD” by “MY KEYWORD”.
Moreover using the underscore in the “name” of my test has a real interest from end-user point of view in my use-case.