Automation using Robot Framework
A lot more to discuss Robot Framework, but here I am trying to highlight only the important topics for future deep dive.
Robot Framework is a Python-based, extensible keyword-driven automation framework for acceptance testing, acceptance test-driven development (ATDD), behavior-driven development (BDD) and robotic process automation (RPA)
It has simple plain text syntax and it can be extended easily with libraries implemented using Python or Java and it utilizes the keyword-driven testing approach
Architecture
What is Test Libraries?
Test libraries contain lowest-level keywords, often called library keywords, which actually interact with the system under test.
Standard Library
The test libraries are used across the Robot Framework. The BuiltIn library important, a set of generic keywords needed often. It is imported automatically and thus always available.
http://robotframework.org/robotframework/latest/libraries/BuiltIn.html
Other standard libraries need to be imported like other libraries, but there is no install them.
External Library
Custom libraries can be implemented based on requirements specific. Example: SeleniumLibrary and SwingLibrary
Remote Library
Test Libraries in one machine and Robot Framework running in another machine.
Test library APIs
Three different test library APIs
Static API
Methods which map directly to the keyword names. Keywords also take the same arguments as the method implemented.
The Robot Framework uses reflection to find out what public methods the library class or module contains.
https://docs.python.org/3/library/inspect.html
def greet(name):
print 'Hello %s!' % name
Dynamic API
The class that implements a method to get the names of the keywords they implement, and another method to execute a named keyword with given arguments.
Robot Framework discovers what keywords a library implements, what arguments and documentation these keywords have, and how the keywords are actually executed
One of the benefits of the dynamic API is that you have more flexibility in organizing your library. With the static API, you must have all keywords in one class or module, whereas with the dynamic API, you can, for example, implement each keyword as a separate class
https://github.com/robotframework/PythonLibCore/blob/master/src/robotlibcore.py
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#dynamic-library-api
Hybrid API
A hybrid between the static API and the dynamic API. When implementing a test library in Python, the hybrid API has the same dynamic capabilities as the actual dynamic API. A great benefit with it is that there is no need to have special methods for getting keyword arguments and documentation.
Example: Telnet library
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#hybrid-library-api
Test Tools
Libdoc
Tool for generating keyword documentation for test libraries and resource files in HTML and XML formats
python -m robot.libdoc TestSystem TestSystem.html
Testdoc
Tool for generating high-level documentation based on test cases.
python -m robot.testdoc my_test.robot testdoc.html
Tidy
Tool for cleaning up and changing the format of Robot Framework test data files.
python -m robot.tidy messed_up_tests.robot cleaned_up_tests.robot
Rebot
Tool for generating logs and reports based on XML outputs and for combining multiple outputs together.
Test Data
*** Settings ***
Documentation A test suite with a single test for valid login.
...
... This test has a workflow that is created using keywords in
... the imported resource file.
Resource resource.robot
*** Test Cases ***
Valid Login
Open Browser To Login Page
Input Username demo
Input Password mode
Submit Credentials
Welcome Page Should Be Open
[Teardown] Close Browser
Settings
Importing test libraries, resource files and variable files.
Defining metadata for test suites and test cases.
Variables
Defining variables that can be used elsewhere in the test data.
Test Cases
Creating test cases from available keywords.
Tasks
Creating tasks using available keywords. A single file can only contain either test cases or tasks.
Keywords
Creating user keywords from existing lower-level keywords
Comments
Additional comments or data. Ignored by Robot Framework.
Reference:
https://github.com/robotframework/RobotDemo
https://robotframework.org/#documentation
https://github.com/robotframework/HowToWriteGoodTestCases
https://github.com/robotframework/PythonLibCore https://github.com/robotframework/IntroSlides