【问题标题】:RobotFramework : AttributeError: 'list' object has no attribute 'startswith'RobotFramework:AttributeError:'list'对象没有属性'startswith'
【发布时间】:2019-10-11 09:20:31
【问题描述】:

使用机器人框架,

我正在尝试使用 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'

【问题讨论】:

    标签: python selenium robotframework robots.txt


    【解决方案1】:

    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}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-20
      • 2020-05-26
      • 2012-12-21
      • 1970-01-01
      • 2019-08-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多