使用机器人框架检查for循环的多个条件

时间:2017-02-17 10:05:17

标签: robotframework

我正在尝试使用机器人框架检查for循环中的多个条件,但它永远不会返回true。

:FOR    ${RowIndex} IN RANGE    0   ${rowscount}    
    ${ColumnText1}  Get Text    //*[@id='RadSearchGrid_ctl00__${RowIndex}']/td[3]       
    ${ColumnText2}  Get Text    //*[@id='RadSearchGrid_ctl00__${RowIndex}']/td[4]       
    ${ColumnText3}  Get Text    //*[@id='RadSearchGrid_ctl00__${RowIndex}']/td[5]       
    ${bStatus}  | Run Keywords |    Should Contain |    ${ColumnText1} and ${ColumnText2} and ${ColumnText3}    | ${VoucherNumber} and ${Voucherdate} and ${VoucherAmount}
    Exit For Loop If    ${bStatus}  

$ {bStatus}永远不会返回true。

1 个答案:

答案 0 :(得分:4)

尝试这样的事情

    :FOR    ${RowIndex} IN RANGE    0   ${rowscount}    
        ${ColumnText1}  Get Text    //*[@id='RadSearchGrid_ctl00__${RowIndex}']/td[3]       
        ${ColumnText2}  Get Text    //*[@id='RadSearchGrid_ctl00__${RowIndex}']/td[4]       
        ${ColumnText3}  Get Text    //*[@id='RadSearchGrid_ctl00__${RowIndex}']/td[5]       

       ${bStatus}=   Run Keyword And Return Status   Run Keywords   Should Contain   ${ColumnText1}   ${VoucherNumber}   AND  Should Contain    ${ColumnText2}   ${Voucherdate}   AND   Should Contain    ${ColumnText3}   ${VoucherAmount}

        Exit For Loop If    ${bStatus}