Add "Get Variable Type" keyword to BuiltIn library by b-vamsipunnam · Pull Request #5683 · robotframework/robotframework · GitHub
Skip to content

Add "Get Variable Type" keyword to BuiltIn library#5683

Open
b-vamsipunnam wants to merge 1 commit into
robotframework:masterfrom
b-vamsipunnam:feature/add-get-variable-type-keyword
Open

Add "Get Variable Type" keyword to BuiltIn library#5683
b-vamsipunnam wants to merge 1 commit into
robotframework:masterfrom
b-vamsipunnam:feature/add-get-variable-type-keyword

Conversation

@b-vamsipunnam

Copy link
Copy Markdown

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:

${type}=    Get Variable Type    ${value}

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:

    • string
    • integer
    • float
    • boolean
    • list
    • dictionary
    • tuple
    • set
    • none
  • 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:

  • String values
  • Integer values
  • Float values
  • Boolean values
  • Lists
  • Dictionaries
  • Tuples
  • Sets
  • None values
  • Custom objects

Files Changed

  • src/robot/libraries/BuiltIn.py
  • atest/testdata/standard_libraries/builtin/get_variable_type.robot
  • atest/robot/standard_libraries/builtin/get_variable_type.robot

Related Issues

No existing issue found.

Thank you for your review and feedback.

@pekkaklarck

Copy link
Copy Markdown
Member

@b-vamsipunnam

Copy link
Copy Markdown
Author

@b-vamsipunnam b-vamsipunnam changed the title Add Get Variable Type keyword to BuiltIn library Add "Get Variable Type" keyword to BuiltIn library Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants