I suspect there are better ways to solve the problem you're trying to solve, but here's a literal answer to your question.
Robot has a keyword named get variables which returns a dictionary of all known robot variables. Robot also has a keyword named evaluate which lets you run arbitrary python code. In that code, you can reference robot variables by using the special syntax $varname
.
Using those keywords, you can create a dictionary comprehension that creates a new dictionary for you.
In the following example, and using the data from your original question, the keyword Get user variables
will return a dictionary that looks like this:
{
'Volte_user_1': samsung,
'Volte_user_02': HTC
}
Note that if you have other variables that have the string "user" in their name, they will show up in the list too.
*** Keywords ***
Get user variables
[Documentation]
... Return a dictionary of key/value pairs where the keys
... are all robot variables that have _user_ as part of
... their name.
${vars}= get variables
${user variables}= evaluate
... {name[2:-1]:value for (name,value) in $vars.items() if "_user_" in name}
[Return] ${user variables}
*** Test Cases ***
Example
${phones}= get user variables
should be equal ${phones['Volte_user_01']} samsung
should be equal ${phones['Volte_user_02']} HTC