Hi does anybody know why I cannot reference suite variable defined in TC1 and then referencing it TC2 within one suite I am getting error : Variable not found Running both tests is ok, but runnig tc1 and then tc2 will produce this error Python 2.7.13 Ride: 1.7.3.1 Thanx a lot TC1 TC2
Asked
Active
Viewed 1,931 times
-3
-
3Add a sample code, without it the question is too vague. How are you setting the variable in TC1, with which keyword? The default variable scope is the current case, only. – Todor Minakov Apr 12 '19 at 15:18
-
2The problem is definitely somewhere in your code. This is a feature or robot that has thoroughly been tested. There is no way we can solve this problem unless you can show us a [mcve] that reproduces the problem. – Bryan Oakley Apr 12 '19 at 15:25
-
@TodorMinakov, thanx for your comment , I have updated my question with code snippets from TC1 and TC2 – Branio Apr 15 '19 at 06:38
-
@BryanOakley , I ve added example pics from both cases, I d like to know that for how long is the suite variable stored? is it remembered until TC is run again , or this scenario works only if TC1 and TC2 are runned in sequence. thanx – Branio Apr 15 '19 at 06:41
-
Please don't post pictures of code. As for how long a suite variable is stored, it's stored for the life of the suite. – Bryan Oakley Apr 15 '19 at 14:20
1 Answers
1
Try next simple code and say if it works, main point here is where you define suite variable by Set Suite Variable
, it should be in the first test case or in the one of the setups(Test/Suite Setup):
*** Settings ***
Library Collections
*** Test Cases ***
TestCase1
Log to Console ${EMPTY}
Set Suite Variable ${suite_variable} case1
Log To Console I'm in case 1: ${suite_variable}
TestCase2
Log to Console ${EMPTY}
${variables} Get Variables
Dictionary Should Contain Key ${variables} \${suite_variable}
Log To Console I'm in case 2: ${suite_variable}

drFunJohn
- 199
- 4
-
I tried, running TestCase1 and right after TestCase2 works correctly, but then I run let say TC3 and than did again TestCase2 and it failled with: | FAIL | Dictionary does not contain key '${suite_variable}'. For how long is the suite variable stored or persisted? – Branio Apr 15 '19 at 06:31
-
Until Suite is finished. If you run full suite it should work. If you run each test case separately by `pybot` command it will not work. I suggest create simple script without any actions to see if it works or not and publish it here. – drFunJohn Apr 15 '19 at 07:02