Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get multiple elements and print in Robot Framework- SeleniumLibrary?

${get_t}=    Get Text    //h6[@class='MuiTypography-root MuiTypography-subtitle2']
Log    ${get_t}
${get_t1}=    Get Element Count    xpath://h6[@class='MuiTypography-root MuiTypography-subtitle2']
Log    ${get_t1}
${get_t3}=    Get WebElements    xpath://h6[@class='MuiTypography-root MuiTypography-subtitle2']
Log    ${get_t3}

when I get Count it shows the count but when i print it using Get WebElements it doens't print the text. If I give Get Text it print the first text alone.

enter image description here

Xpath enter image description here

like image 463
Pradap Pandian Avatar asked Oct 29 '25 11:10

Pradap Pandian


1 Answers

What do you want to achieve - get/print the text of each element? Because Get Webelements does just what its name says - returns you a list of matching elements - selenium element objects. Having that, if you want to print the text of each one, just iterate over the list and call Get Text on each member:

FOR    ${el}    IN    @{get_t3}
    ${txt}=    Get Text    ${el}
    Log    ${txt}
END
like image 154
Todor Minakov Avatar answered Nov 01 '25 03:11

Todor Minakov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!