I have written a few test cases but some of them can be reused instead of writing them again in the new scripts. So if I have an Input text keyword for one field declared on one page how can that be used in an another test cases w/o having to mention the same keyword and locator again.
-
Welcome to Stack Overflow were we try to help with your programming difficulties. In order to do so it is common to provide a minimal reproducible example to show what you are working and a description of the actual and desired outcome. Anything else that you've tried is also helpful to know. To understand what makes a good question read through the How to Ask of the help center.– A. KootstraNov 18, 2018 at 18:54
3 Answers
You can create a user defined Keyword in robot framework and paste your test case scripts inside the keyword then use keyword to execute your tests
Follow this documentation to create a user defined keywords,
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#creating-user-keywords
I would advise you to look at this Link
Robot Framework allows the use of Keywords, I would suggest to create a diffrent folder with all the keywords e.g To open the browser or login with a user to website or what ever you want.
You can create your logic inside the keyword section, and then pass the Name of the Custom Created keyword (Equal String) to the Test script.
Example of Keywords.
keywords.robot
*** Keywords ***
Equal String
Should be equal Hello Hello
Tests.robot
*** Settings ***
Resource keywords.robot
*** Test Cases ***
Validate Equal String
Equal String
You can only share keywords, not tests. https://github.com/robotframework/robotframework/issues/2591