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

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

使用 RobotFramework,

我正在尝试使用 FOR 循环检索 Webelements 标签。

${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}

我在 FOR 循环中遇到错误。请纠正我。

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

获取的WebElements是一个列表,所以你应该在for循环中使用@引用变量:

${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}