Home

Iterate and Log UUIDs Using Robot Framework

13 views

In a .robot file, you can use Robot Framework's built-in looping constructs to iterate over the items in a list. Here's how you can list all UUIDs iteratively using Robot Framework:

*** Settings ***
Library    Collections

*** Variables ***
${RESULT_DICT}    {"uuid_lst": [{"Uuid": "UUID1"}, {"Uuid": "UUID2"}, {"Uuid": "UUID3"}]}

*** Test Cases ***
Iterate Over UUIDs
    # Get the list of UUID dictionaries
    ${uuid_list}=    Get From Dictionary    ${RESULT_DICT}    uuid_lst
    
    # Iterate over each dictionary in the list
    :FOR    ${uuid_dict}    IN    @{uuid_list}
    \    ${uuid}=    Get From Dictionary    ${uuid_dict}    Uuid
    \    Log    UUID: ${uuid}

Here's what the script does:

  • Get From Dictionary: This keyword is used to extract the list of dictionaries from ${RESULT_DICT} with the key uuid_lst.
  • :FOR Loop: Iterates over each dictionary in the list captured in ${uuid_list}.
  • Get From Dictionary (inside loop): Retrieves the UUID from the current dictionary.
  • Log: Outputs the UUID to the log.

This will print each UUID in the list during the test execution. Remember to replace the example UUIDs with your actual data or make sure your variable structures align with this format.