Define a keyword containing a variable within robot framework
I'm currently using robot framework for a project with Gherkin language strategy (Given When Then).
My feature file is as below:
*** Settings ***
Documentation
... In Order to eat a dessert safely,
... As a king
... I want to not take a lethal dessert
Library eat_or_pass.Eat_or_pass
*** Test cases ***
Lethal Dessert
[Template] The result of $hungriness should be $dessert
very hungry apple pie
hungry biscuit
not very hungry apple
*** Keywords ***
The result of $hungriness should be $dessert
Given the king is $hungriness
Then the related dessert is $dessert
I would like to link the keyword " Given the king is $hungriness" to its python definition contained in the python module Eat_or_pass.py which is currently implemented as below:
class Eat_or_pass(object):
def given_the_king_is_hungriness(self):
pass
When I run robot framework, I have this error :
"Lethal Dessert | FAIL |
No keyword with name 'Given the king is $hungriness' found."
And I don't know how to solve it. Does anyone can help me on the subject?
python templates robotframework bdd gherkin
add a comment |
I'm currently using robot framework for a project with Gherkin language strategy (Given When Then).
My feature file is as below:
*** Settings ***
Documentation
... In Order to eat a dessert safely,
... As a king
... I want to not take a lethal dessert
Library eat_or_pass.Eat_or_pass
*** Test cases ***
Lethal Dessert
[Template] The result of $hungriness should be $dessert
very hungry apple pie
hungry biscuit
not very hungry apple
*** Keywords ***
The result of $hungriness should be $dessert
Given the king is $hungriness
Then the related dessert is $dessert
I would like to link the keyword " Given the king is $hungriness" to its python definition contained in the python module Eat_or_pass.py which is currently implemented as below:
class Eat_or_pass(object):
def given_the_king_is_hungriness(self):
pass
When I run robot framework, I have this error :
"Lethal Dessert | FAIL |
No keyword with name 'Given the king is $hungriness' found."
And I don't know how to solve it. Does anyone can help me on the subject?
python templates robotframework bdd gherkin
add a comment |
I'm currently using robot framework for a project with Gherkin language strategy (Given When Then).
My feature file is as below:
*** Settings ***
Documentation
... In Order to eat a dessert safely,
... As a king
... I want to not take a lethal dessert
Library eat_or_pass.Eat_or_pass
*** Test cases ***
Lethal Dessert
[Template] The result of $hungriness should be $dessert
very hungry apple pie
hungry biscuit
not very hungry apple
*** Keywords ***
The result of $hungriness should be $dessert
Given the king is $hungriness
Then the related dessert is $dessert
I would like to link the keyword " Given the king is $hungriness" to its python definition contained in the python module Eat_or_pass.py which is currently implemented as below:
class Eat_or_pass(object):
def given_the_king_is_hungriness(self):
pass
When I run robot framework, I have this error :
"Lethal Dessert | FAIL |
No keyword with name 'Given the king is $hungriness' found."
And I don't know how to solve it. Does anyone can help me on the subject?
python templates robotframework bdd gherkin
I'm currently using robot framework for a project with Gherkin language strategy (Given When Then).
My feature file is as below:
*** Settings ***
Documentation
... In Order to eat a dessert safely,
... As a king
... I want to not take a lethal dessert
Library eat_or_pass.Eat_or_pass
*** Test cases ***
Lethal Dessert
[Template] The result of $hungriness should be $dessert
very hungry apple pie
hungry biscuit
not very hungry apple
*** Keywords ***
The result of $hungriness should be $dessert
Given the king is $hungriness
Then the related dessert is $dessert
I would like to link the keyword " Given the king is $hungriness" to its python definition contained in the python module Eat_or_pass.py which is currently implemented as below:
class Eat_or_pass(object):
def given_the_king_is_hungriness(self):
pass
When I run robot framework, I have this error :
"Lethal Dessert | FAIL |
No keyword with name 'Given the king is $hungriness' found."
And I don't know how to solve it. Does anyone can help me on the subject?
python templates robotframework bdd gherkin
python templates robotframework bdd gherkin
asked Nov 14 '18 at 9:38
TataSetelem TataSetelem
61
61
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Robot code:
*** Settings ***
Documentation
... In Order to eat a dessert safely,
... As a king
... I want to not take a lethal dessert
Library ./EatOrPass.py
*** Test Cases ***
Lethal Dessert
[Template] The Result Of $hungriness Should Be $dessert
very hungry apple pie
hungry biscuit
not very hungry apple
*** Keywords ***
The Result Of $hungriness Should Be $dessert
Given The King Is $hungriness
Then The Related Dessert Is $dessert
python lib:
from robot.api.deco import keyword
class EatOrPass(object):
@keyword('The King Is $hungriness')
def the_king_is(self, hungriness):
pass
@keyword('The Related Dessert Is $dessert')
def the_related_dessert_is(self, dessert):
pass
I suggest you to use CamelCase for python and to use 4 spaces for RF (better readability).
It is probably working but I don't have the robot.api.deco installed on my laptop and I am not allowed to install it. Do you have another solution?
– TataSetelem
Nov 15 '18 at 9:01
You can always do it without embedded arguments. In such case the decorator isn't needed and you just define and use your keywords with normal argument(s). Is it OK for you? Can you manage it by yourself?
– Jan Kovařík
Nov 15 '18 at 12:11
Of course I can but it means that I have to multiply the number of test cases ! I can handle it, anyway thank you very much for your help
– TataSetelem
Nov 15 '18 at 13:32
I don't think so. Your python-defined keywords would be without embedded arguments, but the one robot-defined keyword can stay as it is. All the suggested robot code could be like it is in answer except you would call your python-based keywords likeGiven The King Is<four spaces here>$hungriness.
– Jan Kovařík
Nov 15 '18 at 14:33
I used the code source of robot.api.deco public library, I implemented exactly on this way but the keywords are still not found. Do you have another solution?
– TataSetelem
Nov 28 '18 at 14:48
|
show 2 more comments
*** Keywords ***
The result of $hungriness should be $dessert
Given The king Is Hungriness
It Should be Given The king Is Hungriness not Given the king is $hungriness
class Eat_or_pass(object):
def given_the_king_is_hungriness(self):
pass
2
If I do that, robot will not take into account that I have various variables for the hungriness.
– TataSetelem
Nov 14 '18 at 13:22
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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%2f53297025%2fdefine-a-keyword-containing-a-variable-within-robot-framework%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Robot code:
*** Settings ***
Documentation
... In Order to eat a dessert safely,
... As a king
... I want to not take a lethal dessert
Library ./EatOrPass.py
*** Test Cases ***
Lethal Dessert
[Template] The Result Of $hungriness Should Be $dessert
very hungry apple pie
hungry biscuit
not very hungry apple
*** Keywords ***
The Result Of $hungriness Should Be $dessert
Given The King Is $hungriness
Then The Related Dessert Is $dessert
python lib:
from robot.api.deco import keyword
class EatOrPass(object):
@keyword('The King Is $hungriness')
def the_king_is(self, hungriness):
pass
@keyword('The Related Dessert Is $dessert')
def the_related_dessert_is(self, dessert):
pass
I suggest you to use CamelCase for python and to use 4 spaces for RF (better readability).
It is probably working but I don't have the robot.api.deco installed on my laptop and I am not allowed to install it. Do you have another solution?
– TataSetelem
Nov 15 '18 at 9:01
You can always do it without embedded arguments. In such case the decorator isn't needed and you just define and use your keywords with normal argument(s). Is it OK for you? Can you manage it by yourself?
– Jan Kovařík
Nov 15 '18 at 12:11
Of course I can but it means that I have to multiply the number of test cases ! I can handle it, anyway thank you very much for your help
– TataSetelem
Nov 15 '18 at 13:32
I don't think so. Your python-defined keywords would be without embedded arguments, but the one robot-defined keyword can stay as it is. All the suggested robot code could be like it is in answer except you would call your python-based keywords likeGiven The King Is<four spaces here>$hungriness.
– Jan Kovařík
Nov 15 '18 at 14:33
I used the code source of robot.api.deco public library, I implemented exactly on this way but the keywords are still not found. Do you have another solution?
– TataSetelem
Nov 28 '18 at 14:48
|
show 2 more comments
Robot code:
*** Settings ***
Documentation
... In Order to eat a dessert safely,
... As a king
... I want to not take a lethal dessert
Library ./EatOrPass.py
*** Test Cases ***
Lethal Dessert
[Template] The Result Of $hungriness Should Be $dessert
very hungry apple pie
hungry biscuit
not very hungry apple
*** Keywords ***
The Result Of $hungriness Should Be $dessert
Given The King Is $hungriness
Then The Related Dessert Is $dessert
python lib:
from robot.api.deco import keyword
class EatOrPass(object):
@keyword('The King Is $hungriness')
def the_king_is(self, hungriness):
pass
@keyword('The Related Dessert Is $dessert')
def the_related_dessert_is(self, dessert):
pass
I suggest you to use CamelCase for python and to use 4 spaces for RF (better readability).
It is probably working but I don't have the robot.api.deco installed on my laptop and I am not allowed to install it. Do you have another solution?
– TataSetelem
Nov 15 '18 at 9:01
You can always do it without embedded arguments. In such case the decorator isn't needed and you just define and use your keywords with normal argument(s). Is it OK for you? Can you manage it by yourself?
– Jan Kovařík
Nov 15 '18 at 12:11
Of course I can but it means that I have to multiply the number of test cases ! I can handle it, anyway thank you very much for your help
– TataSetelem
Nov 15 '18 at 13:32
I don't think so. Your python-defined keywords would be without embedded arguments, but the one robot-defined keyword can stay as it is. All the suggested robot code could be like it is in answer except you would call your python-based keywords likeGiven The King Is<four spaces here>$hungriness.
– Jan Kovařík
Nov 15 '18 at 14:33
I used the code source of robot.api.deco public library, I implemented exactly on this way but the keywords are still not found. Do you have another solution?
– TataSetelem
Nov 28 '18 at 14:48
|
show 2 more comments
Robot code:
*** Settings ***
Documentation
... In Order to eat a dessert safely,
... As a king
... I want to not take a lethal dessert
Library ./EatOrPass.py
*** Test Cases ***
Lethal Dessert
[Template] The Result Of $hungriness Should Be $dessert
very hungry apple pie
hungry biscuit
not very hungry apple
*** Keywords ***
The Result Of $hungriness Should Be $dessert
Given The King Is $hungriness
Then The Related Dessert Is $dessert
python lib:
from robot.api.deco import keyword
class EatOrPass(object):
@keyword('The King Is $hungriness')
def the_king_is(self, hungriness):
pass
@keyword('The Related Dessert Is $dessert')
def the_related_dessert_is(self, dessert):
pass
I suggest you to use CamelCase for python and to use 4 spaces for RF (better readability).
Robot code:
*** Settings ***
Documentation
... In Order to eat a dessert safely,
... As a king
... I want to not take a lethal dessert
Library ./EatOrPass.py
*** Test Cases ***
Lethal Dessert
[Template] The Result Of $hungriness Should Be $dessert
very hungry apple pie
hungry biscuit
not very hungry apple
*** Keywords ***
The Result Of $hungriness Should Be $dessert
Given The King Is $hungriness
Then The Related Dessert Is $dessert
python lib:
from robot.api.deco import keyword
class EatOrPass(object):
@keyword('The King Is $hungriness')
def the_king_is(self, hungriness):
pass
@keyword('The Related Dessert Is $dessert')
def the_related_dessert_is(self, dessert):
pass
I suggest you to use CamelCase for python and to use 4 spaces for RF (better readability).
edited Nov 14 '18 at 12:18
answered Nov 14 '18 at 11:29
Jan KovaříkJan Kovařík
1,1521615
1,1521615
It is probably working but I don't have the robot.api.deco installed on my laptop and I am not allowed to install it. Do you have another solution?
– TataSetelem
Nov 15 '18 at 9:01
You can always do it without embedded arguments. In such case the decorator isn't needed and you just define and use your keywords with normal argument(s). Is it OK for you? Can you manage it by yourself?
– Jan Kovařík
Nov 15 '18 at 12:11
Of course I can but it means that I have to multiply the number of test cases ! I can handle it, anyway thank you very much for your help
– TataSetelem
Nov 15 '18 at 13:32
I don't think so. Your python-defined keywords would be without embedded arguments, but the one robot-defined keyword can stay as it is. All the suggested robot code could be like it is in answer except you would call your python-based keywords likeGiven The King Is<four spaces here>$hungriness.
– Jan Kovařík
Nov 15 '18 at 14:33
I used the code source of robot.api.deco public library, I implemented exactly on this way but the keywords are still not found. Do you have another solution?
– TataSetelem
Nov 28 '18 at 14:48
|
show 2 more comments
It is probably working but I don't have the robot.api.deco installed on my laptop and I am not allowed to install it. Do you have another solution?
– TataSetelem
Nov 15 '18 at 9:01
You can always do it without embedded arguments. In such case the decorator isn't needed and you just define and use your keywords with normal argument(s). Is it OK for you? Can you manage it by yourself?
– Jan Kovařík
Nov 15 '18 at 12:11
Of course I can but it means that I have to multiply the number of test cases ! I can handle it, anyway thank you very much for your help
– TataSetelem
Nov 15 '18 at 13:32
I don't think so. Your python-defined keywords would be without embedded arguments, but the one robot-defined keyword can stay as it is. All the suggested robot code could be like it is in answer except you would call your python-based keywords likeGiven The King Is<four spaces here>$hungriness.
– Jan Kovařík
Nov 15 '18 at 14:33
I used the code source of robot.api.deco public library, I implemented exactly on this way but the keywords are still not found. Do you have another solution?
– TataSetelem
Nov 28 '18 at 14:48
It is probably working but I don't have the robot.api.deco installed on my laptop and I am not allowed to install it. Do you have another solution?
– TataSetelem
Nov 15 '18 at 9:01
It is probably working but I don't have the robot.api.deco installed on my laptop and I am not allowed to install it. Do you have another solution?
– TataSetelem
Nov 15 '18 at 9:01
You can always do it without embedded arguments. In such case the decorator isn't needed and you just define and use your keywords with normal argument(s). Is it OK for you? Can you manage it by yourself?
– Jan Kovařík
Nov 15 '18 at 12:11
You can always do it without embedded arguments. In such case the decorator isn't needed and you just define and use your keywords with normal argument(s). Is it OK for you? Can you manage it by yourself?
– Jan Kovařík
Nov 15 '18 at 12:11
Of course I can but it means that I have to multiply the number of test cases ! I can handle it, anyway thank you very much for your help
– TataSetelem
Nov 15 '18 at 13:32
Of course I can but it means that I have to multiply the number of test cases ! I can handle it, anyway thank you very much for your help
– TataSetelem
Nov 15 '18 at 13:32
I don't think so. Your python-defined keywords would be without embedded arguments, but the one robot-defined keyword can stay as it is. All the suggested robot code could be like it is in answer except you would call your python-based keywords like
Given The King Is<four spaces here>$hungriness.– Jan Kovařík
Nov 15 '18 at 14:33
I don't think so. Your python-defined keywords would be without embedded arguments, but the one robot-defined keyword can stay as it is. All the suggested robot code could be like it is in answer except you would call your python-based keywords like
Given The King Is<four spaces here>$hungriness.– Jan Kovařík
Nov 15 '18 at 14:33
I used the code source of robot.api.deco public library, I implemented exactly on this way but the keywords are still not found. Do you have another solution?
– TataSetelem
Nov 28 '18 at 14:48
I used the code source of robot.api.deco public library, I implemented exactly on this way but the keywords are still not found. Do you have another solution?
– TataSetelem
Nov 28 '18 at 14:48
|
show 2 more comments
*** Keywords ***
The result of $hungriness should be $dessert
Given The king Is Hungriness
It Should be Given The king Is Hungriness not Given the king is $hungriness
class Eat_or_pass(object):
def given_the_king_is_hungriness(self):
pass
2
If I do that, robot will not take into account that I have various variables for the hungriness.
– TataSetelem
Nov 14 '18 at 13:22
add a comment |
*** Keywords ***
The result of $hungriness should be $dessert
Given The king Is Hungriness
It Should be Given The king Is Hungriness not Given the king is $hungriness
class Eat_or_pass(object):
def given_the_king_is_hungriness(self):
pass
2
If I do that, robot will not take into account that I have various variables for the hungriness.
– TataSetelem
Nov 14 '18 at 13:22
add a comment |
*** Keywords ***
The result of $hungriness should be $dessert
Given The king Is Hungriness
It Should be Given The king Is Hungriness not Given the king is $hungriness
class Eat_or_pass(object):
def given_the_king_is_hungriness(self):
pass
*** Keywords ***
The result of $hungriness should be $dessert
Given The king Is Hungriness
It Should be Given The king Is Hungriness not Given the king is $hungriness
class Eat_or_pass(object):
def given_the_king_is_hungriness(self):
pass
edited Nov 14 '18 at 11:25
answered Nov 14 '18 at 11:19
Batchu BhargavaBatchu Bhargava
374
374
2
If I do that, robot will not take into account that I have various variables for the hungriness.
– TataSetelem
Nov 14 '18 at 13:22
add a comment |
2
If I do that, robot will not take into account that I have various variables for the hungriness.
– TataSetelem
Nov 14 '18 at 13:22
2
2
If I do that, robot will not take into account that I have various variables for the hungriness.
– TataSetelem
Nov 14 '18 at 13:22
If I do that, robot will not take into account that I have various variables for the hungriness.
– TataSetelem
Nov 14 '18 at 13:22
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.
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%2f53297025%2fdefine-a-keyword-containing-a-variable-within-robot-framework%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