[Python] How to get testcases [Tags] from robot framework

Discussão em 'Python' iniciado por Stack, Janeiro 20, 2025.

  1. Stack

    Stack Membro Participativo

    There is some 'test_suite.robot' file, that contains several test cases with specific tags.

    *** Settings ***

    *** Test Cases ***
    TC One
    [Documentation] ...
    [Tags] one
    Log to console...

    TC Two
    [Documentation] ...
    [Tags] two
    Log to console...


    I need to get [Tags] values in my method in a Python file. How can I get them (in detail)?

    I know, that Robot provides several automatic variables. Among these are ${TEST NAME}, ${TEST DOCUMENTATION} and @{TEST TAGS}.

    In Python I get the suite name in this way and receive the correct name:

    from robot.libraries.BuiltIn import BuiltIn
    suite_name = BuiltIn().get_variable_value("${SUITE NAME}") => Test Suite


    BUT! When I try to use the same approach with @{TEST TAGS}, I receive None:

    from robot.libraries.BuiltIn import BuiltIn
    suite_name = BuiltIn().get_variable_value("@{TEST TAGS}") => None


    I think the problem is that I coded it wrong. Tell me how to write the correct code.

    Continue reading...

Compartilhe esta Página