Skip to content

Robot Framework examples

pytabify provides its official Robot Framework wrapper, PyTabifyLibrary.

Quick start Keyword reference

Minimal configuration

Import the library
*** Settings ***
Library    Pytabify

Create a table from records

In-memory RobotDataTable
*** Test Cases ***
Crear tabla desde registros
    ${records}=    Create List
    ...    ${{ {"name": "Alice", "age": 30} }}
    ...    ${{ {"name": "Bob", "age": 25} }}
    ${table}=    Pytabify.Create Data Table From Records    ${records}
    ${headers}=    Pytabify.Get Data Table Headers    ${table}
    Should Be Equal    ${headers}    ${["name", "age"]}

Read a row by attribute or key

Attribute and key access
*** Test Cases ***
Inspeccionar fila
    ${records}=    Create List
    ...    ${{ {"name": "Alice", "age": 30} }}
    ${table}=    Pytabify.Create Data Table From Records    ${records}
    ${row}=    Pytabify.Get Data Table Row    ${table}    0
    Should Be Equal As Strings    ${row.name}    Alice
    Should Be Equal As Integers    ${row}[age]    30

Update and save the table

Add a column and save JSON
*** Test Cases ***
Mutar tabla y guardar
    ${records}=    Create List
    ...    ${{ {"name": "Alice", "age": 30} }}
    ...    ${{ {"name": "Bob", "age": 25} }}
    ${table}=    Pytabify.Create Data Table From Records    ${records}
    ${table}=    Pytabify.Set Data Table Value    ${table}    0    country    MX
    Pytabify.Save Data Table To Json    ${table}    people.json
  • RobotDataTable iterates adapted rows.
  • RobotDataRow supports attribute and key access.
  • Get Data Table Headers accepts both RobotDataTable and native DataTable.
  • Your tests run in Robot and you want to avoid manually mapping rows.
  • You need a stable tabular contract between keywords.

Compatibility

Several operations accept both RobotDataTable and native DataTable, simplifying mixed Python/Robot flows.

Read a JSON file
Create a table from a file
${table}=    Pytabify.Create Data Table From File    people.json
${headers}=    Pytabify.Get Data Table Headers    ${table}