| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
What's the use case for this functionality? |
Sorry, something went wrong.
|
Hi @pekkaklarck , One use case is building generic, reusable keywords that need to handle different input types at runtime. For example: ${type}= Get Variable Type ${data}
IF '${type}' == 'list'
Process List ${data}
ELSE IF '${type}' == 'dictionary'
Process Dictionary ${data}
ELSE
Process Scalar ${data}
ENDAnother scenario is working with dynamic data returned from APIs, JSON files, variable files, or custom libraries, where it can be helpful to quickly check or debug the runtime type of a value before processing it further. For example, verifying that a returned field is a list or dictionary as expected. The main motivation is improving readability and discoverability rather than adding functionality that isn't already possible with Evaluate. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Adds a new BuiltIn keyword Get Variable Type that returns the runtime type of a value using Robot Framework friendly type names.
Motivation
Robot Framework currently lacks a direct BuiltIn keyword for inspecting the runtime type of a value. Users typically rely on Python evaluation syntax:
${type}= Evaluate type($value).__name__While functional, this mixes Python-specific syntax into test data, reduces readability for non-Python users, and is less discoverable than a dedicated keyword.
The new keyword offers a cleaner, more self-documenting alternative:
This is particularly useful for dynamic test data handling, building reusable and generic keywords, debugging variables, and implementing type-aware logic in keyword-driven and data-driven automation.
Implementation
Added Get Variable Type keyword in src/robot/libraries/BuiltIn.py
Returns normalized, user-friendly type names:
Returns object for custom classes and other unsupported types
Properly handles bool before int because bool is a subclass of int in Python
Tests
Added acceptance tests covering:
Files Changed
Related Issues
No existing issue found.
Thank you for your review and feedback.