![](/img/trans.png)
[英]Python AttributeError: 'dict' object has no attribute 'startswith' when 'dict' in a list
[英]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'
Get 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}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.