Abstract Keywords in Robot Framework












0















is it possible to implement abstract keywords, so that you can avoid duplicated "code" and also avoid technical arguments in the actual test implementation? It's also very important to me, that the abstract Keyword is not usable in any actual test implementation.



What I want to have is something like that:



*** Abstract Keywords ***
Open Menu Item
[Arguments] ${menu}
Click Element ${menu}

*** Keywords ***
Open Home
Open Menu Item Home

Open Setup
Open Menu Item Setup


Does Robot Framework support abstraction?










share|improve this question


















  • 1





    What meaning do you put in "abstract"? The commonly used one (see: Java) specifies there should be no implementation in such methods; and they are used within abstract classes, so inheritors must provide the actual implementation according to their shape. In your sample, that's not the case, you're reusung the implementation defined in the want-to-be abstract keyword; and there's no concept of classes in RF. So what are you actually trying to achieve? Disallow usage of keywords in test cases, only in other keywords?

    – Todor Minakov
    Nov 23 '18 at 19:36






  • 1





    I agree with @todor and want to add one comment. Robot Framework is not a programming language. These constructs you're using are alien to it's DSL for an obvious reason: they don't belong there. As mentioned by Bryan you can do much more in Python and this kind of approach really should be developed in that layer. Keep the Robot Framework side of things simple. So, please elaborate on why this is so important to you in the Robot Framework layer.

    – A. Kootstra
    Nov 23 '18 at 22:04
















0















is it possible to implement abstract keywords, so that you can avoid duplicated "code" and also avoid technical arguments in the actual test implementation? It's also very important to me, that the abstract Keyword is not usable in any actual test implementation.



What I want to have is something like that:



*** Abstract Keywords ***
Open Menu Item
[Arguments] ${menu}
Click Element ${menu}

*** Keywords ***
Open Home
Open Menu Item Home

Open Setup
Open Menu Item Setup


Does Robot Framework support abstraction?










share|improve this question


















  • 1





    What meaning do you put in "abstract"? The commonly used one (see: Java) specifies there should be no implementation in such methods; and they are used within abstract classes, so inheritors must provide the actual implementation according to their shape. In your sample, that's not the case, you're reusung the implementation defined in the want-to-be abstract keyword; and there's no concept of classes in RF. So what are you actually trying to achieve? Disallow usage of keywords in test cases, only in other keywords?

    – Todor Minakov
    Nov 23 '18 at 19:36






  • 1





    I agree with @todor and want to add one comment. Robot Framework is not a programming language. These constructs you're using are alien to it's DSL for an obvious reason: they don't belong there. As mentioned by Bryan you can do much more in Python and this kind of approach really should be developed in that layer. Keep the Robot Framework side of things simple. So, please elaborate on why this is so important to you in the Robot Framework layer.

    – A. Kootstra
    Nov 23 '18 at 22:04














0












0








0








is it possible to implement abstract keywords, so that you can avoid duplicated "code" and also avoid technical arguments in the actual test implementation? It's also very important to me, that the abstract Keyword is not usable in any actual test implementation.



What I want to have is something like that:



*** Abstract Keywords ***
Open Menu Item
[Arguments] ${menu}
Click Element ${menu}

*** Keywords ***
Open Home
Open Menu Item Home

Open Setup
Open Menu Item Setup


Does Robot Framework support abstraction?










share|improve this question














is it possible to implement abstract keywords, so that you can avoid duplicated "code" and also avoid technical arguments in the actual test implementation? It's also very important to me, that the abstract Keyword is not usable in any actual test implementation.



What I want to have is something like that:



*** Abstract Keywords ***
Open Menu Item
[Arguments] ${menu}
Click Element ${menu}

*** Keywords ***
Open Home
Open Menu Item Home

Open Setup
Open Menu Item Setup


Does Robot Framework support abstraction?







testing automated-tests robotframework






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 12:56









TheOnionMasterTheOnionMaster

609




609








  • 1





    What meaning do you put in "abstract"? The commonly used one (see: Java) specifies there should be no implementation in such methods; and they are used within abstract classes, so inheritors must provide the actual implementation according to their shape. In your sample, that's not the case, you're reusung the implementation defined in the want-to-be abstract keyword; and there's no concept of classes in RF. So what are you actually trying to achieve? Disallow usage of keywords in test cases, only in other keywords?

    – Todor Minakov
    Nov 23 '18 at 19:36






  • 1





    I agree with @todor and want to add one comment. Robot Framework is not a programming language. These constructs you're using are alien to it's DSL for an obvious reason: they don't belong there. As mentioned by Bryan you can do much more in Python and this kind of approach really should be developed in that layer. Keep the Robot Framework side of things simple. So, please elaborate on why this is so important to you in the Robot Framework layer.

    – A. Kootstra
    Nov 23 '18 at 22:04














  • 1





    What meaning do you put in "abstract"? The commonly used one (see: Java) specifies there should be no implementation in such methods; and they are used within abstract classes, so inheritors must provide the actual implementation according to their shape. In your sample, that's not the case, you're reusung the implementation defined in the want-to-be abstract keyword; and there's no concept of classes in RF. So what are you actually trying to achieve? Disallow usage of keywords in test cases, only in other keywords?

    – Todor Minakov
    Nov 23 '18 at 19:36






  • 1





    I agree with @todor and want to add one comment. Robot Framework is not a programming language. These constructs you're using are alien to it's DSL for an obvious reason: they don't belong there. As mentioned by Bryan you can do much more in Python and this kind of approach really should be developed in that layer. Keep the Robot Framework side of things simple. So, please elaborate on why this is so important to you in the Robot Framework layer.

    – A. Kootstra
    Nov 23 '18 at 22:04








1




1





What meaning do you put in "abstract"? The commonly used one (see: Java) specifies there should be no implementation in such methods; and they are used within abstract classes, so inheritors must provide the actual implementation according to their shape. In your sample, that's not the case, you're reusung the implementation defined in the want-to-be abstract keyword; and there's no concept of classes in RF. So what are you actually trying to achieve? Disallow usage of keywords in test cases, only in other keywords?

– Todor Minakov
Nov 23 '18 at 19:36





What meaning do you put in "abstract"? The commonly used one (see: Java) specifies there should be no implementation in such methods; and they are used within abstract classes, so inheritors must provide the actual implementation according to their shape. In your sample, that's not the case, you're reusung the implementation defined in the want-to-be abstract keyword; and there's no concept of classes in RF. So what are you actually trying to achieve? Disallow usage of keywords in test cases, only in other keywords?

– Todor Minakov
Nov 23 '18 at 19:36




1




1





I agree with @todor and want to add one comment. Robot Framework is not a programming language. These constructs you're using are alien to it's DSL for an obvious reason: they don't belong there. As mentioned by Bryan you can do much more in Python and this kind of approach really should be developed in that layer. Keep the Robot Framework side of things simple. So, please elaborate on why this is so important to you in the Robot Framework layer.

– A. Kootstra
Nov 23 '18 at 22:04





I agree with @todor and want to add one comment. Robot Framework is not a programming language. These constructs you're using are alien to it's DSL for an obvious reason: they don't belong there. As mentioned by Bryan you can do much more in Python and this kind of approach really should be developed in that layer. Keep the Robot Framework side of things simple. So, please elaborate on why this is so important to you in the Robot Framework layer.

– A. Kootstra
Nov 23 '18 at 22:04












1 Answer
1






active

oldest

votes


















7














Short answer: no



Robot framework has no concept of abstract keywords. You can certainly create new keywords that call other keywords like you do in your example, but there is no way to prevent someone from calling Open Menu Item directly if they know how to import it.



Slightly longer answer: yes, if you write keywords in python



You can certainly do what you want in python. Robot has a well-defined mechanism for how it knows which functions are keywords and which are not in a keyword library. Your abstract keyword can simply be a private function or method that doesn't get exported. Your exported keywords can use this function internally, but it won't be available directly as a keyword to your test cases.






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447146%2fabstract-keywords-in-robot-framework%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7














    Short answer: no



    Robot framework has no concept of abstract keywords. You can certainly create new keywords that call other keywords like you do in your example, but there is no way to prevent someone from calling Open Menu Item directly if they know how to import it.



    Slightly longer answer: yes, if you write keywords in python



    You can certainly do what you want in python. Robot has a well-defined mechanism for how it knows which functions are keywords and which are not in a keyword library. Your abstract keyword can simply be a private function or method that doesn't get exported. Your exported keywords can use this function internally, but it won't be available directly as a keyword to your test cases.






    share|improve this answer




























      7














      Short answer: no



      Robot framework has no concept of abstract keywords. You can certainly create new keywords that call other keywords like you do in your example, but there is no way to prevent someone from calling Open Menu Item directly if they know how to import it.



      Slightly longer answer: yes, if you write keywords in python



      You can certainly do what you want in python. Robot has a well-defined mechanism for how it knows which functions are keywords and which are not in a keyword library. Your abstract keyword can simply be a private function or method that doesn't get exported. Your exported keywords can use this function internally, but it won't be available directly as a keyword to your test cases.






      share|improve this answer


























        7












        7








        7







        Short answer: no



        Robot framework has no concept of abstract keywords. You can certainly create new keywords that call other keywords like you do in your example, but there is no way to prevent someone from calling Open Menu Item directly if they know how to import it.



        Slightly longer answer: yes, if you write keywords in python



        You can certainly do what you want in python. Robot has a well-defined mechanism for how it knows which functions are keywords and which are not in a keyword library. Your abstract keyword can simply be a private function or method that doesn't get exported. Your exported keywords can use this function internally, but it won't be available directly as a keyword to your test cases.






        share|improve this answer













        Short answer: no



        Robot framework has no concept of abstract keywords. You can certainly create new keywords that call other keywords like you do in your example, but there is no way to prevent someone from calling Open Menu Item directly if they know how to import it.



        Slightly longer answer: yes, if you write keywords in python



        You can certainly do what you want in python. Robot has a well-defined mechanism for how it knows which functions are keywords and which are not in a keyword library. Your abstract keyword can simply be a private function or method that doesn't get exported. Your exported keywords can use this function internally, but it won't be available directly as a keyword to your test cases.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 15:45









        Bryan OakleyBryan Oakley

        216k22259421




        216k22259421






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447146%2fabstract-keywords-in-robot-framework%23new-answer', 'question_page');
            }
            );

            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







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'