-1
${BEFORE_RESTART}=  Get Restart Count

This variable is local to one test case in robot framework. I want to access the same in other test cases of same test suite.

I tried to figure out ways using Set Global Variables But didnt work.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685

2 Answers2

2

You can use Set Global Variable or Set Suite Variable like this:

Set Global Variable    ${BEFORE_RESTART}    ${empty}
Set Suite Variable     ${BEFORE_RESTART}    ${empty}

Your variable will change in your testcase, when you run the

${BEFORE_RESTART}=    Get Restart Count 

line.

cris
  • 183
  • 2
  • 8
1

Alternatively, you may use Variable file ( a python file with vars) and inject it in robot execution as this is equivalent to GLOBAL scope. python file as simple as :

BEFORE_RESTART=0

attach such file with -V parameter to robot execution:

python -m robot.run -V <path to python file> <rest of robot commands>

Although I would suggest to try to keep scope of variables at least limited to SUITE level (with Set Suite Variable) if your testcases shares that var within same suite.

jozefow
  • 626
  • 3
  • 14