It is never too late to become smarter or better…Never stop learning.
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).
Always remember if you are bored, it means that you are doing it wrong. Don’t be bored of learning..keep learning and sharing.
Do follow us to learn and share:-
Best Practices in Robot Framework(RF):-
- Implement suite setup and suite tear down for common setup like launching application, closing application. We can create an initialization file for it.
- 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.)
- 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.
- 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.
Note:– We used sublime editor for creating our code structure.
Code structure :-
TestCase:- is name of our testSuite.It contains 2 test cases as per below example.
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.
Resources:-It contains the page specific keywords.
Variables:- It contains our variable definition(we have taken python file for the same)
|Code structure when opened in Sublime editor.|
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.
Note:- When we would try to open the code in RIDE, we need to manually browse the path for External Resources.
On right side of RIDE -> Under Add Import ->Resource
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.
Hope you enjoyed our best practices in RF tutorial.