-
-
Notifications
You must be signed in to change notification settings - Fork 21
Variable inspector shows a local variable which is not accessible #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
for me this seems to be the correct behavior. the first break is in a test case, then the local scope is the test scope, the second break is in a keyword, now the local scope is the keyword scope, but you look in the suite scope. a keyword cannot see the variables in test scope. but if you came back from the keyword execution then your are back in test scope and the test scope becomes the local scope: what did you expect? |
This is where I disagree. The User Guide states: "Variables with the test case scope are visible in a test case and in all user keywords the test uses.". However, Perhaps I am wrong, but during debugging I expect to have access to all variables which are listed on the left, grouped by their scope local/test/suite/global. Do you agree with that? In the second screenshot you see Robot Framework failing correctly because I try to access such a local variable in a sub keyword. To make that work, I would need to use a kw argument and pass the local variable to the keyword. |
Ah ok, now I understand. The problem here is that when robot creates a new execution context, the existing variables are simply copied into the new context. This means that each execution context has a complete copy of the variables from the parent context. This is somewhat memory-consuming, but it's easy to handle because when you want to read a variable, you don't have to consider the parent context. In the debugger, I need to figure out the differences between the individual contexts. So, if I want to display the variables of the suite context, I take the variables from the suite context and check which of them are not in the global context. For the test context, I use the suite context. And for the local variables, I need to check if I am in a keyword and then subtract either the suite context or the test context. Unfortunately, I cannot determine how a variable was defined, whether with Therefore, the suite variables also show the local variables created in the suite. I need to figure out how to do this better, so I'll leave this issue open for now. |
👍 Thanks Daniel, I appreciate your efforts! |
I am reproducing the example in the Robot Framework User Guide about the VAR syntax:
https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#var-syntax
Then I start the Debugger with a breakpoint here.
This is correct: the variable
${local}
is a local one:When I debug into the
keyword
Keyword, this does not seem correct to me:The Variable inspector shows
local
as a test variable, which is not true.My expectation is that the variables shown in the list are accessible at the current line.
(Or am I wrong...?)
The text was updated successfully, but these errors were encountered: