How to make the list to a table using robot framework

836 views
Skip to first unread message

mm rr

unread,
May 25, 2023, 4:52:42 AM5/25/23
to robotframework-users
OUTLOOK.Open Application
    ${emails}=  Get Emails
    Log List    ${emails}    @{filtered_emails}    Filter Emails    ${emails}
    ${lastest_email}    Get From List    ${filtered_emails}    -1
    Log    ${lastest_email}[Body]
    Set Task Variable    ${latest_body}    ${lastest_email}[Body]
    Log    ${latest_body}
    ${specific_text}=    Extract Specific Text    ${latest_body}
    Log    ${specific_text}
    Log To Console   ${specific_text}
    Log List    ${specific_text}
    ${test}    Get From List    ${specific_text}    0By implementing the code above, what i got from Log List    ${specific_text} is:
List length is 18 and it contains following items:
0: 025-DT-S24255
1: TCNU3848789
2: 025-DT-S24245
3: EITU9083782
4: 025-DT-S24247
5: EMCU8601448
6: 025-DT-S24251
7: MAGU5370276
8: 025-DT-S24253
9: EGSU9025768
10: 025-DT-S24257
11: EITU9071890
12: 025-DT-S24259
13: EMCU8242570
14: 025-DT-S24249
15: TLLU4852866
16: 025-DT-S24317
17: TLLU7650426Based on the list above, i want the even index in the list store under a table's first column, while the odd index in the list store under a table's second column, how can i do

Hélio Guilherme

unread,
May 25, 2023, 5:56:35 AM5/25/23
to robotframework-users
I don't know if this is what you want, but here is a runnable example:
 
*** Settings ***
Library           Collections

*** Variables ***
@{DATA}           025-DT-S24255    TCNU3848789    025-DT-S24245    EITU9083782    025-DT-S24247    EMCU8601448    025-DT-S24251    MAGU5370276    025-DT-S24253    EGSU9025768    025-DT-S24257    EITU9071890    025-DT-S24259    EMCU8242570    025-DT-S24249    TLLU4852866    025-DT-S24317
...               TLLU7650426

*** Test Cases ***
table maker
    Comment    Log List    ${DATA}
    @{column_one}=    Create List
    @{column_two}=    Create List
    FOR    ${idx}    ${element}    IN ENUMERATE    @{DATA}
        ${odd}=    Evaluate    ${idx}%2 == 0
        Run Keyword If    ${odd}    Append To List    ${column_one}    ${element}
        ...    ELSE    Append To List    ${column_two}    ${element}
    END
    Comment    Log Many    ${column_one}    ${column_two}
    @{table}=    Create List
    Append To List    ${table}    <table><tr><th>Column One</th><th>Column Two</th>
    FOR    ${z}    IN ZIP    ${column_one}    ${column_two}
        Append To List    ${table}    <tr><td>${z[0]}</td><td>${z[1]}</td></tr>
    END
    Append To List    ${table}    </table>
    Log    ${table}    level=HTML


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/6fa4d1bc-bb20-4aad-830a-fa36aebd95ben%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages