Search code examples
robotframework

Update resource file variable in new resource file


Here is the problem context: I have two robot files: file1.robot and file2.robot.

file1.robot

Defines in the *** Variables *** section a list: @{real} with some values.

Now I have a second file: file2.robot which import the file1.robot with the instruction:

Resource ./file1.robot

When I try to update the real list in the file2.robot in the variables section using the command:

${real}= Append To List ${real} connectModule

I get the messages: Recursive variable definition. and Variable '${real}' not found. Any idea how I could do it? Sincerely


Solution

  • It can be done exactly as you have described it. It is difficult to say where you have mistake from what you have shown us, keyword Append To List has no return value that however should not result in your error. But below code should work

    test.robot

    Library    Collections
    Resource    ${CURDIR}/unnecessary.resource
    
    
    
    *** Test Cases ***   
    test
        Collections.Append To List    ${test_list}    new    values
        Log    ${test_list}
    

    useful.resource

    *** Variables ***
    @{test_list}    some    values
    

    unnecessary.resource

    *** Settings ***
    Resource          ${CURDIR}/useful.resource
    

    I have all 3 files in the same folder