Reputation: 1
I have the code below that doesn't seem to persist the value of a variable. I am trying to increment it per call however the increment is not persistent in the variable.
*** Settings ***
Library lib.py
*** Variables ***
${x} 0
${inc} 1
*** Keywords ***
My keyword
${x} = evaluate ${x}+${inc}
Log To Console ${x}
# [return] ${x}
*** Test Cases ***
Run endless loop
Run Endless Loop My keyword
================================================================= lib.py
from robot.libraries.BuiltIn import BuiltIn
def call_keyword(keyword):
return BuiltIn().run_keyword(keyword)
def run_endless_loop(f):
while True:
call_keyword(f)
Am curious what's happening here...
Upvotes: 0
Views: 339
Reputation: 7271
Your keyword works fine, only you are incrementing a local variable.
So in every iteration x
will be 0
and it will be incremented to 1
.
You have to store the returned value on suite level using the Set Suite Variable
keyword.
*** Variables ***
${x} 0
${inc} 1
*** Test Cases ***
Test
My keyword
My keyword
My keyword
*** Keywords ***
My keyword
${x} = evaluate ${x}+${inc}
Set Suite Variable ${x}
Log To Console ${x}
Upvotes: 1