Reputation: 83
I'm trying to use this list of strings as a single keyword argument but get an error at runtime.
[ ERROR ] Error in file Variables.robot Invalid variable name '${LIST_TEST_ATTRIBUTES}
I can ctrl-click on the ${LIST_TEST_ATTRIBUTES} and it does find the variable within the Variables.robot file
Variables.robot
*** Variables ***
${LIST_TEST_ATTRIBUTES} = ["${access_engine_ip}","${analytics_engine_ip}","${AUT_Version}","${browser_type}","${ESX_server_ipaddress}","${device_type_x450_g2}"]
Test.robot
*** Settings ***
Resource Variables.robot
*** Test Cases ***
Initialize Test
initialize test variables ${LIST_TEST_ATTRIBUTES}
Upvotes: 3
Views: 18593
Reputation: 20067
That's not the syntax of creating a list in the Variables section; here's the correct one - you prepend its name with @
, not $
, and pass all members separated with at least two spaces:
*** Variables ***
@{LIST_TEST_ATTRIBUTES} ${access_engine_ip} ${analytics_engine_ip} ${AUT_Version} ${browser_type} ${ESX_server_ipaddress} ${device_type_x450_g2}
Now in your sample, all the members are references to other variables. LIST_TEST_ATTRIBUTES
is instantiated the moment the suite is created - which means all these members have to already have values at this moment - e.g. defined in an imported resource file, or somewhere before the list variable in this file.
If that's not the case - their values are still not set, but that happens a bit later, you can do something different - have a keyword that creates the list variable, sets it with a suite scope; and then call the keyword when needed:
*** Variables ***
# the value of this variable is set through the "Set The Value Of The List Var" keyword
${LIST_TEST_ATTRIBUTES} ${None} # this "declaration" is not needed, but it's a good practice - thus you show to the other users there is this suite-level var
*** Keywords ***
Set The Value Of The List Var
${LIST_TEST_ATTRIBUTES}= Create List ${access_engine_ip} ${analytics_engine_ip} ${AUT_Version} ${browser_type} ${ESX_server_ipaddress} ${device_type_x450_g2}
Set Suite Variable ${LIST_TEST_ATTRIBUTES}
You'll call the keyword Set The Value Of The List Var
when the values of its members are already set, and the list variable will be available for all cases after that call.
Upvotes: 4
Reputation: 3737
What you really want is to define the list in a Python file. Using a Python file makes easier the initialization of variables.
Or correct the syntax like Bryan Oakley pointed. See User Guide
Example:
Variables.py
LIST_TEST_ATTRIBUTES = ["${access_engine_ip}", "${analytics_engine_ip}", "${AUT_Version}", "${browser_type}", "${ESX_server_ipaddress}", "${device_type_x450_g2}"]
Test.robot
*** Settings ***
Variables Variables.py
*** Test Cases ***
Initialize Test
initialize test variables ${LIST_TEST_ATTRIBUTES}
*** Keywords ***
initialize test variables
[Arguments] ${arg1}
Log ${arg1}
Upvotes: 3