How to get All Text in robot framework ?

后端 未结 6 1043
走了就别回头了
走了就别回头了 2021-02-06 15:01

Consider the following source code,

    <
6条回答
  •  天命终不由人
    2021-02-06 15:15

    Though the top-rated answer is fully working - and the most xpath-ish :), let me add an option I don't see proposed yet - using the Get Webelements keyword. E.g.:

    @{locators}=     Get Webelements    xpath=//div[@id='groupContainer']//li[@class='contactNameItemContainer']//span
    ${result}=       Create List
    
    :FOR   ${locator}   in    @{locators}
    \       ${name}=    Get Text    ${locator}
    \       Append To List  ${result}  ${name}
    

    It'll generate and return a list of all matching elements, on which you just iterate on. It might be a tad faster than xpath's [index] reference because the dom is evaluated once - but don't hold me accountable if that's not fully true :)

提交回复
热议问题