Sample-Is Variable Declared

Setting Value
Library OperatingSystem
Variable Value
${ELSE} 1==1
Test Case Action Arguments
Test Is Variable Declared [Documentation] Check a variable whether exists.
comment check scalar variable
${result} Is Variable Declared test_scalar_var
Should Be Equal As Strings ${result} FALSE
${test_scalar_var} Set Variable 123
${result} Is Variable Declared test_scalar_var
Should Be Equal As Strings ${result} TRUE
comment check list variable
${result} Is Variable Declared test_list_var
Should Be Equal As Strings ${result} FALSE
@{test_list_var} Create List 1 2
... 3
${result} Is Variable Declared test_list_var
Should Be Equal As Strings ${result} TRUE
comment check test variable
Set Test Variable ${test_var} 123
${result} Is Variable Declared test_var
Should Be Equal As Strings ${result} TRUE
Set Suite Variable ${suite_var} 123
${result} Is Variable Declared suite_var
Should Be Equal As Strings ${result} TRUE
Set Global Variable ${global_var} 123
${result} Is Variable Declared global_var
Should Be Equal As Strings ${result} TRUE
log %{PATH}
${result} Is Variable Declared PATH
Should Be Equal As Strings ${result} TRUE
Keyword Action Arguments
Is Variable Declared [Arguments] ${var}
[Documentation] Check a variable named ${var} whether exists.
@{check_result1} Run Keyword And Ignore Error Variable Should Exist ${${var}}
@{check_result2} Run Keyword And Ignore Error Get Environment Variable ${var}
${result} Set Variable If '@{check_result1}[0]' == 'PASS' or '@{check_result2}[0]' == 'PASS' TRUE
... ${ELSE} FALSE
[Return] ${result}