How to Preserve Object state in Robot Framework
<p>I am fairly new to Robot Framework and I have written a few keywords, which invokes methods in a .py file. All these Python methods are placed in a class in the file llk_machine.py.</p>

<p>Below is my TestCase file:</p>

<pre><code>    *** Settings ***

Variables         /repo/user/var_attero.py

Library           %{ROBOTREPO}/Lib/LIB_LLK/llk_machine.py    WITH NAME    class1

    *** Keywords ***
CONNECT

        [Documentation]    Connects to Machine.
        ${CONNECT_PASS_or_FAIL}=    class1.llk_Connect
        [Return]    ${CONNECT_PASS_or_FAIL}

CONFIGURE_DELAY

         [Arguments]    ${port_number}=1    ${fixed_delay}=25000
         [Documentation]    Configure impairment in the active testbed.
         ${pass_fail_status}=    class1.llk_Config_Impair_fixed    ${port_number}  ${fixed_delay}
         [Return]    ${pass_fail_status}
</code></pre>

<p>llk_Connect and llk_Config_Impair_fixed are two methods in Python file. Through keyword connect I am connecting to the machine. When I execute this testcase it executes just fine and passes. Then when I select the second test case for configuring the delay, I get an error saying "Not able to connect the machine". But I have already connected to the machine through the first testcase and when I checked physically, the machine is connected to my computer.</p>

<p>So I think that another object is being instantiated when I select the second keyword and a new socket connection to the machine is being requested which is obviously failing as the machine is already talking to other socket and can't accept another connection.</p>

<p>When I execute both the test cases simultaneously, it is working just fine. The problem arises when I execute them separately, one after another.</p>

<p>How to prevent the creation of new object for every test case and have only one object throughout the entire test cycle.Please help me out.</p>

<p>Thanks.</p>