Catalog / Robot Framework Testing and Debugging Cheat Sheet
Robot Framework Testing and Debugging Cheat Sheet
A comprehensive cheat sheet covering essential techniques for testing and debugging Robot Framework projects, including logging, debugging tools, and best practices for robust test automation.
Logging and Reporting
Basic Logging
Robot Framework provides built-in keywords for logging messages at different levels.
|
Example:
|
Logging Levels
|
For detailed debugging information. |
|
General information about test execution (default). |
|
Warnings about potential issues. |
|
Errors that occurred during test execution. |
|
More detailed info than DEBUG. Used for troubleshooting. |
Setting Log Level
You can set the log level using command-line options.
Alternatively, you can set the log level programmatically.
|
Debugging Techniques
Using `Pause Execution`
The
This keyword will print a prompt in the console, allowing you to execute Robot Framework keywords and Python code interactively. |
Interactive Debugging with `rpdb`
|
Example:
Then, run your test and connect to the debugger using a client like |
Using `Evaluate` for Debugging
The
|
Handling Exceptions
Try-Except Blocks
Robot Framework allows you to handle exceptions using
|
Handling Specific Exceptions
You can catch specific exceptions using the fully qualified name of the exception class. |
|
You can use multiple |
|
Using `Run Keyword And Expect Error`
The
|
The expected error can be a specific error message, a regular expression, or an exception class name. |
Best Practices for Debugging
Isolate Issues
When encountering a test failure, try to isolate the issue by running the failing test case individually. This can help narrow down the source of the problem. Use the
|
Use Descriptive Logging
Add descriptive log messages to your tests to provide context and information about what the test is doing. This can make it easier to understand the test flow and identify the cause of failures. Include relevant variable values and expected outcomes in your log messages. |
Review Test Reports
Robot Framework generates detailed HTML reports and logs after each test execution. Review these reports to identify failures, errors, and warnings. The reports provide information about the execution time, status, and log messages for each test case. |