【问题标题】:Running a block of code in until loop Robot Framework在直到循环机器人框架中运行一段代码
【发布时间】:2017-08-28 14:39:13
【问题描述】:

我在 Robot Framework 中为代码块编写循环时遇到问题。

此代码首先检查一些值(最小和当前),然后比较它们,然后通过输入文本增加另一个值(数量)。我希望执行此代码块,直到满足 Current 大于 Minimum 的条件。

我应该如何写这样的条件? 提前致谢。

${Minimum}= Get Table Cell  xpath=...   5   3
${Current}= Get Table Cell  xpath=...   5   4   

${status}    ${value}=    Run Keyword And Ignore Error    
...    Should be true    ${Current} > ${Minimum}

${quantity}=    Get Value   xpath=
...    Run Keyword If   '${status}' == 'FAIL'   
...       Input Text    xpath=${quantity+10}

【问题讨论】:

    标签: robotframework


    【解决方案1】:

    好的,我设法用简单的 FOR 循环和 EXIT FOR LOOP 在 ELSE 条件下做到这一点。

    : FOR   ${i}    IN RANGE    1   999                         
        ${BoxesMinimum}=    Get Table Cell  xpath=//someid    5    3        
        ${BoxesCurrent}=    Get Table Cell  xpath=//someid    5    4                    
    
        ${status}   ${value}=   Run Keyword and Ignore Error    
        ...    Should be true    ${BoxesCurrent} > ${BoxesMinimum}      
    
        ${quantity}=    Get Value   xpath=//someid
    
        Run Keyword If  '${status}' == 'FAIL'   
        ...              Input Text    xpath=//someid    ${quantity+10}    
        ...    ELSE    Exit for loop
    

    【讨论】:

      猜你喜欢
      • 2017-04-20
      • 1970-01-01
      • 2018-08-09
      • 2020-12-29
      • 2016-03-15
      • 2020-02-19
      • 2016-11-18
      • 2015-12-08
      • 2017-07-02
      相关资源
      最近更新 更多