2017-02-17 58 views
1

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

: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

我不认为'运行Keywords'or'如果Contain'返回任何值。根据[当前文档](http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Should%20Contain)如果未找到期望值,应该包含失败。 –

+0

@Würgspaß对不起,它是运行关键字和返回状态 – vinu

回答

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} 
+0

它给出了错误:关键字'BuiltIn.Should Contain'预计2至4个参数,得到了9. – vinu

+1

编辑答案,请使用 '$ {bStatus} =运行关键字和返回状态运行关键字应包含$ {ColumnText1} $ {VoucherNumber}并且应该包含$ {ColumnText2} $ {Voucherdate}并且应该包含$ {ColumnText3} $ {VoucherAmount}' – Vivi

+0

是的,它现在可以工作。谢谢 – vinu