Best Practices:- Working with Robot Framework – User friendly Tech help
It is never too late to become smarter or better…Never stop learning.n
We started with installation of Robot framework, followed with first test case and further implementing the same in RIDE.Today we would focus on some of the best practices while working with Robot Framework(RF).
n
Always remember if you are bored, it means that you are doing it wrong. Don’t be bored of learning..keep learning and sharing.
n
Do follow us to learn and share:-
n
n
Best Practices in Robot Framework(RF):-
n
Settings:-
n
- n
- Implement suite setup and suite tear down for common setup like launching application, closing application. We can create an initialization file for it.
n
n
Variables:-
n
- n
- Use variables instead of direct hard coding of values and put variables inside a .variable file for easy maintenance.
- Avoid variable assignment in Test cases; try to create test cases in domain specific language (thus to avoid programming concepts, like reduce the approach if taking return from a test step and passing it in next test step.)
n
n
n
Test Cases:-
n
- n
- Avoid test case dependencies. Treat each test case as an independent identity.
- Try to minimize the test steps in a test case and should not exceed the level of 10 steps.
- Use Tags to segregate test cases like smoke or regression.
n
n
n
n
Keywords:-
n
- n
- Keyword name should describe what need to be done rather than how it needs to be done
- Avoid complex logic inside this like for loops; rather utilize the external resources file to handle the programming part.
- Avoid sleep, rather implement utilize inbuilt keywords like wait until page contains (selenium2Library).
- Better not to have documentation all if it is not required. Like if test case or keyword name is self describing than why to go for documentation.
n
n
n
n
n
Practical implementation:-
n
Note:– We used sublime editor for creating our code structure.
n
nDownload Link for the Code
n
n
Code structure :-
TestCase:- is name of our testSuite.It contains 2 test cases as per below example.
n
lib:- It contains the App and Common .txt files. App.txt contains the keywords specific to application. Common.txt contains the keywords for setup and tear down of application.
n
Resources:-It contains the page specific keywords.
n
Variables:- It contains our variable definition(we have taken python file for the same)
n
Code structure when opened in Sublime editor. |
n
Extract the code to run the TestCase.robot file, we can run the same in RIDE also but we need to establish the link for external resources used.
n
Note:- When we would try to open the code in RIDE, we need to manually browse the path for External Resources.
n
On right side of RIDE -> Under Add Import ->Resource
n
Same need to be done for Variables file.(i.e our GlobalVar.py file)
After adding the resources our solution explorer of RIDE would look as below.
Now we can run the test case in RIDE by pressing F8.
n
Hope you enjoyed our best practices in RF tutorial.
n
nLearn Robot Framework
nLearn Selenium