Search code examples
robotframework

How to get TAG name which was passed in command line in Robot Framework?


I am running test cases using robot --include smoke /

I need smoke tag which was passed in command line argument in test case.


Solution

  • The current tags are available in the Test level through the built-in variable ${TEST TAGS}; you can iterate over its members to see what the case has:

    FOR    ${tag}    IN    @{TEST TAGS}
        Log    tag: ${tag}
    END
    

    Yet that will give you all tags a case has assigned; so in your case it will return "smoke", but will also return "sanity", "feature" and all others it might have.

    There's no exposed user-level variable/keyword to get what exactly were the tags set for the current execution; using the RF API you may be able to get a reference to the current execution context and access such property (if it's present).