使用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'
答案 0 :(得分:3)
获取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}