【问题标题】:Robot Framework, how to get the value of odd row table from the RangeRobot Framework,如何从 Range 中获取奇数行表的值
【发布时间】:2021-09-04 18:09:15
【问题描述】:

我有一个新任务,我需要先获取生成的表,然后从该表中,我需要验证表的奇数行

到目前为止,这是我的脚本

    ${Count}  get element count  ${Accounting_Table_Row}
    
    FOR    ${i}    IN RANGE    999999
        Exit For Loop If    ${i} == ${Count}
        ${M}  get text 
   xpath=//div/[@id'GeneratedTable']/table/tr[${count}]
        Run Keyword if    "${M}" != "0"    fail  transaction is not validated    ELSE    pass execution  
        transaction is validated
    END

我得到了所有生成的表,但我只需要奇数行表。我怎样才能得到它?

【问题讨论】:

    标签: for-loop selenium-webdriver robotframework


    【解决方案1】:

    我们使用 Python 模块运算符(除法的余数)。这是一个例子:

    *** Test Cases ***
    cicle
        ${Count}=    Set Variable    ${55}
        FOR    ${i}    IN RANGE    ${Count}
            ${Oddness}=    Set Variable If    ${i%2} != 0    "Odd"    "Even"
            Log To Console    var=\${i}=${i} is ${Oddness}
        END
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-22
      • 2017-02-08
      • 2021-06-26
      • 2021-04-04
      • 2016-09-30
      • 2020-12-31
      • 1970-01-01
      • 2020-01-02
      相关资源
      最近更新 更多