Search code examples
robotframeworkrpadynamic-variables

Robotframework, How to define a dynamic variable name


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 ..

Solution

  • This is currently not possible with Robot Framework. You can use "variables inside variables" to resolve the values of variables (see the documentation on this topic) but not to resolve/set the name of the variable itself.

    Though I am afraid that would be confusing anyway. Maybe you can explain your motivations and people can come up with another solution for your problem.