I want to Define variable having dynamic name.
For example
${${FILE}{VAR}}    Create List      // ${FILE} = TEST, ${VAR} = VAR
Then I want to get variable named '${TESTVAR}'.
Here is my Summarized code...
*** Settings ***
Library    SeleniumLibrary
Library    ExcelLibrary
Library    Collections
*** Variables ***
${VAR}=     VAR
*** Keywords ***
Open Document And Assign Variable
    [Arguments]     ${FILE}
    Open Excel Document filename=${FILE}    doc_id=doc_var
    ${${FILE}${VAR}}    Create List    # It doesn't work ..
                The previous answer is not really accurate. This can be achieved exactly with robot's "Variables inside variables" feature like so:
FOR  ${idx}  IN RANGE  3
   ${var_name} =  Catenate  SEPARATOR=_  var  ${idx}
   Set Suite Variable  ${${var_name}}  ${idx}
END
you get:
   var_1=1 
   var_2=2 
   var_3=3 
Please note that variables resolution is happening only for keywords arguments (at least for robot version 3.1.2 that I am using), therefore either one of 'Set test variable', 'Set Suite Variable' or 'Set Global Variable' keywords must be used. The following won't work:
FOR  ${idx}  IN RANGE  3
   ${var_name} =  Catenate  SEPARATOR=_  var  ${idx}
   ${${var_name}} =  ${idx}
END
results in: 
    No keyword with name '${${var_name}} =' found.
For your list case you just need to create a list variable and reassign it to dynamically named variable using the above mentioned keywords
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With