Robot Framework - How to use Global Variable for different keywords
up vote
-1
down vote
favorite
I have this problem where I need to make a variable accessible from different keywords
I have Tried to use set global variable
Keyword.
***Keywords***
Random Name
${Name}= Full Name
set global variable ${Name}
Keyword Name
Random Name
Log ${Name}
Keyword Name2
Random Name
Log ${Name}
*** Test Cases ***
Run Keywords
Keyword Name
Keyword Name2
Full Name Keyword
Import names
def Full_Name(self):
return (names.get_first_name())
Output
So in Keyword Name The value I am getting is John
, but in Keyword Name2 The value is Clair
. I need to keep the value as John
for all of the keywords.
When i try to use the variable without passing the Keyword into the keyword I am not able to access it all.
I also Tried to use set suite variable
but that has the Same Result.
Note: Full Name keyword is a custom library to get random names. also this is only a example code
variables robotframework
|
show 6 more comments
up vote
-1
down vote
favorite
I have this problem where I need to make a variable accessible from different keywords
I have Tried to use set global variable
Keyword.
***Keywords***
Random Name
${Name}= Full Name
set global variable ${Name}
Keyword Name
Random Name
Log ${Name}
Keyword Name2
Random Name
Log ${Name}
*** Test Cases ***
Run Keywords
Keyword Name
Keyword Name2
Full Name Keyword
Import names
def Full_Name(self):
return (names.get_first_name())
Output
So in Keyword Name The value I am getting is John
, but in Keyword Name2 The value is Clair
. I need to keep the value as John
for all of the keywords.
When i try to use the variable without passing the Keyword into the keyword I am not able to access it all.
I also Tried to use set suite variable
but that has the Same Result.
Note: Full Name keyword is a custom library to get random names. also this is only a example code
variables robotframework
This code won't run, it is full of errors. If it did run, it likely still wouldn't reproduce the problem since you callRandom Name
in every keyword so it stands to reason you would get a random name in every keyword (assumingRandom Name
actually sets${name}
to a random name).
– Bryan Oakley
Nov 8 at 11:54
This is a sample code (My code is too large to post it here), I am calling theRandom Name
keyword in every keyword because the global variable${Name}
is not found otherwise, thats my problem, i need to use the${Name}
without passing in the whole keyword. AndRandom Name
does set${Name}
to a random name
– Wojtek T
Nov 8 at 12:02
@BryanOakley i have edited my answer
– Wojtek T
Nov 8 at 12:09
The code you posted still doesn't work. I getNo keyword with name 'Full Name' found.
. When I fix the obvious error, both of the other keywords log "Full Name" just as I would expect.
– Bryan Oakley
Nov 8 at 12:16
1
@WojtekT You should put into an answer and not as an edit to the question itself. :)
– Bence Kaulics
Nov 10 at 20:51
|
show 6 more comments
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I have this problem where I need to make a variable accessible from different keywords
I have Tried to use set global variable
Keyword.
***Keywords***
Random Name
${Name}= Full Name
set global variable ${Name}
Keyword Name
Random Name
Log ${Name}
Keyword Name2
Random Name
Log ${Name}
*** Test Cases ***
Run Keywords
Keyword Name
Keyword Name2
Full Name Keyword
Import names
def Full_Name(self):
return (names.get_first_name())
Output
So in Keyword Name The value I am getting is John
, but in Keyword Name2 The value is Clair
. I need to keep the value as John
for all of the keywords.
When i try to use the variable without passing the Keyword into the keyword I am not able to access it all.
I also Tried to use set suite variable
but that has the Same Result.
Note: Full Name keyword is a custom library to get random names. also this is only a example code
variables robotframework
I have this problem where I need to make a variable accessible from different keywords
I have Tried to use set global variable
Keyword.
***Keywords***
Random Name
${Name}= Full Name
set global variable ${Name}
Keyword Name
Random Name
Log ${Name}
Keyword Name2
Random Name
Log ${Name}
*** Test Cases ***
Run Keywords
Keyword Name
Keyword Name2
Full Name Keyword
Import names
def Full_Name(self):
return (names.get_first_name())
Output
So in Keyword Name The value I am getting is John
, but in Keyword Name2 The value is Clair
. I need to keep the value as John
for all of the keywords.
When i try to use the variable without passing the Keyword into the keyword I am not able to access it all.
I also Tried to use set suite variable
but that has the Same Result.
Note: Full Name keyword is a custom library to get random names. also this is only a example code
variables robotframework
variables robotframework
edited Nov 10 at 20:53
Modus Tollens
4,12632337
4,12632337
asked Nov 8 at 11:27
Wojtek T
998422
998422
This code won't run, it is full of errors. If it did run, it likely still wouldn't reproduce the problem since you callRandom Name
in every keyword so it stands to reason you would get a random name in every keyword (assumingRandom Name
actually sets${name}
to a random name).
– Bryan Oakley
Nov 8 at 11:54
This is a sample code (My code is too large to post it here), I am calling theRandom Name
keyword in every keyword because the global variable${Name}
is not found otherwise, thats my problem, i need to use the${Name}
without passing in the whole keyword. AndRandom Name
does set${Name}
to a random name
– Wojtek T
Nov 8 at 12:02
@BryanOakley i have edited my answer
– Wojtek T
Nov 8 at 12:09
The code you posted still doesn't work. I getNo keyword with name 'Full Name' found.
. When I fix the obvious error, both of the other keywords log "Full Name" just as I would expect.
– Bryan Oakley
Nov 8 at 12:16
1
@WojtekT You should put into an answer and not as an edit to the question itself. :)
– Bence Kaulics
Nov 10 at 20:51
|
show 6 more comments
This code won't run, it is full of errors. If it did run, it likely still wouldn't reproduce the problem since you callRandom Name
in every keyword so it stands to reason you would get a random name in every keyword (assumingRandom Name
actually sets${name}
to a random name).
– Bryan Oakley
Nov 8 at 11:54
This is a sample code (My code is too large to post it here), I am calling theRandom Name
keyword in every keyword because the global variable${Name}
is not found otherwise, thats my problem, i need to use the${Name}
without passing in the whole keyword. AndRandom Name
does set${Name}
to a random name
– Wojtek T
Nov 8 at 12:02
@BryanOakley i have edited my answer
– Wojtek T
Nov 8 at 12:09
The code you posted still doesn't work. I getNo keyword with name 'Full Name' found.
. When I fix the obvious error, both of the other keywords log "Full Name" just as I would expect.
– Bryan Oakley
Nov 8 at 12:16
1
@WojtekT You should put into an answer and not as an edit to the question itself. :)
– Bence Kaulics
Nov 10 at 20:51
This code won't run, it is full of errors. If it did run, it likely still wouldn't reproduce the problem since you call
Random Name
in every keyword so it stands to reason you would get a random name in every keyword (assuming Random Name
actually sets ${name}
to a random name).– Bryan Oakley
Nov 8 at 11:54
This code won't run, it is full of errors. If it did run, it likely still wouldn't reproduce the problem since you call
Random Name
in every keyword so it stands to reason you would get a random name in every keyword (assuming Random Name
actually sets ${name}
to a random name).– Bryan Oakley
Nov 8 at 11:54
This is a sample code (My code is too large to post it here), I am calling the
Random Name
keyword in every keyword because the global variable ${Name}
is not found otherwise, thats my problem, i need to use the ${Name}
without passing in the whole keyword. And Random Name
does set ${Name}
to a random name– Wojtek T
Nov 8 at 12:02
This is a sample code (My code is too large to post it here), I am calling the
Random Name
keyword in every keyword because the global variable ${Name}
is not found otherwise, thats my problem, i need to use the ${Name}
without passing in the whole keyword. And Random Name
does set ${Name}
to a random name– Wojtek T
Nov 8 at 12:02
@BryanOakley i have edited my answer
– Wojtek T
Nov 8 at 12:09
@BryanOakley i have edited my answer
– Wojtek T
Nov 8 at 12:09
The code you posted still doesn't work. I get
No keyword with name 'Full Name' found.
. When I fix the obvious error, both of the other keywords log "Full Name" just as I would expect.– Bryan Oakley
Nov 8 at 12:16
The code you posted still doesn't work. I get
No keyword with name 'Full Name' found.
. When I fix the obvious error, both of the other keywords log "Full Name" just as I would expect.– Bryan Oakley
Nov 8 at 12:16
1
1
@WojtekT You should put into an answer and not as an edit to the question itself. :)
– Bence Kaulics
Nov 10 at 20:51
@WojtekT You should put into an answer and not as an edit to the question itself. :)
– Bence Kaulics
Nov 10 at 20:51
|
show 6 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
I have found a solution. I wasn't calling the Random Name Keyword in my Test case, and also i created a empty variable in the Variable section
*** Variables ***
${Name}
***Keywords***
Random Name
${Name}= Full Name
set global variable ${Name}
Keyword Name
Log ${Name}
Keyword Name2
Log ${Name}
*** Test Cases ***
Run Keywords
Random Name
Keyword Name
Keyword Name2
Now I am getting the Desired output
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
I have found a solution. I wasn't calling the Random Name Keyword in my Test case, and also i created a empty variable in the Variable section
*** Variables ***
${Name}
***Keywords***
Random Name
${Name}= Full Name
set global variable ${Name}
Keyword Name
Log ${Name}
Keyword Name2
Log ${Name}
*** Test Cases ***
Run Keywords
Random Name
Keyword Name
Keyword Name2
Now I am getting the Desired output
add a comment |
up vote
0
down vote
accepted
I have found a solution. I wasn't calling the Random Name Keyword in my Test case, and also i created a empty variable in the Variable section
*** Variables ***
${Name}
***Keywords***
Random Name
${Name}= Full Name
set global variable ${Name}
Keyword Name
Log ${Name}
Keyword Name2
Log ${Name}
*** Test Cases ***
Run Keywords
Random Name
Keyword Name
Keyword Name2
Now I am getting the Desired output
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I have found a solution. I wasn't calling the Random Name Keyword in my Test case, and also i created a empty variable in the Variable section
*** Variables ***
${Name}
***Keywords***
Random Name
${Name}= Full Name
set global variable ${Name}
Keyword Name
Log ${Name}
Keyword Name2
Log ${Name}
*** Test Cases ***
Run Keywords
Random Name
Keyword Name
Keyword Name2
Now I am getting the Desired output
I have found a solution. I wasn't calling the Random Name Keyword in my Test case, and also i created a empty variable in the Variable section
*** Variables ***
${Name}
***Keywords***
Random Name
${Name}= Full Name
set global variable ${Name}
Keyword Name
Log ${Name}
Keyword Name2
Log ${Name}
*** Test Cases ***
Run Keywords
Random Name
Keyword Name
Keyword Name2
Now I am getting the Desired output
answered Nov 12 at 9:55
Wojtek T
998422
998422
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206818%2frobot-framework-how-to-use-global-variable-for-different-keywords%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This code won't run, it is full of errors. If it did run, it likely still wouldn't reproduce the problem since you call
Random Name
in every keyword so it stands to reason you would get a random name in every keyword (assumingRandom Name
actually sets${name}
to a random name).– Bryan Oakley
Nov 8 at 11:54
This is a sample code (My code is too large to post it here), I am calling the
Random Name
keyword in every keyword because the global variable${Name}
is not found otherwise, thats my problem, i need to use the${Name}
without passing in the whole keyword. AndRandom Name
does set${Name}
to a random name– Wojtek T
Nov 8 at 12:02
@BryanOakley i have edited my answer
– Wojtek T
Nov 8 at 12:09
The code you posted still doesn't work. I get
No keyword with name 'Full Name' found.
. When I fix the obvious error, both of the other keywords log "Full Name" just as I would expect.– Bryan Oakley
Nov 8 at 12:16
1
@WojtekT You should put into an answer and not as an edit to the question itself. :)
– Bence Kaulics
Nov 10 at 20:51