RobotFramework : AttributeError: 'list' object has no attribute 'startswith'

Using RobotFramework,

I am trying to retrieve Webelements label by using FOR loop.

${temp}=    Get WebElements    xpath=//*[@class='ui-grid-canvas']
Set Global Variable    ${temp}
${as}    Get Element Count    xpath=//*[@class='ui-grid-canvas']
: FOR    ${ELEMENT}    IN    ${temp}
\    ${as}=    Get Text    ${ELEMENT}

I am getting error at FOR loop. Kindly correct me.

AttributeError: 'list' object has no attribute 'startswith'

1 answer

  • answered 2019-05-24 19:06 Simon

    Get WebElements is a list, so you should use reference the variable with @ in the for loop:

    ${temp}=    Get WebElements    xpath=//*[@class='ui-grid-canvas']
    Set Global Variable    ${temp}
    ${as}    Get Element Count    xpath=//*[@class='ui-grid-canvas']
    : FOR    ${ELEMENT}    IN    @{temp}
    \    ${as}=    Get Text    ${ELEMENT}