Is it possible to access the tags of a keyword defined in a resouce file but in the Python code?

Is it in any way possible to access the Tags of a keyword which is defined in a resource file, but in the python code?

Example:

*** Settings ***

library     my_dummy_library.py


*** Keywords ***

My dummy keyword
      [Tags]      MyTag

      my_python_keyword

And in my_dummy_library.py

@library
class DummyClass:
      ....
      
      @keyword(my_python_keyword)
      def my_python_keyword(self):
            tags = <SOMEHOW GET THE TAGS FROM HERE USING E.G BuiltIn>

I am not able to input the tags etc as variables.

Is there any way to access the tags of the source keyword using e.g. BuiltIn()?

Something like

BuiltIn().get_variable_value("@{KEYWORD TAGS}")

And if not, is there any way I could implement such a feature?

Thanks!

I’m not sure if I understand, but you can set the tags for your keyword in python lib with:
@keyword(tags=[‘tag1’, ‘tag2’]) which will set robot_tags attribute.

One possibility would be using a listener that records the tags in the start_user_keyword method. If it’s only a single library that needs this information, that library itself should probably register that listener.

1 Like

Hello,
Robot Framework does not provide a direct way to retrieve keyword tags dynamically from a resource file in Python. However, you can define tags directly in your Python library using @keyword(tags=[‘MyTag’]). Alternatively, a custom implementation could parse resource files or extend Robot Framework’s execution model.

Best regards,
Crystal