【问题标题】:Robotframework else ifRobotframework else if
【发布时间】:2020-09-11 19:17:28
【问题描述】:

我在 RF 中使用 ELSE IF 时遇到问题。希望你能帮助我。

所以基本上在网页上会有任务要求,但是可能根本没有任务,或者有多个任务。为了解决这个问题,我想创建一个关键字。

*** Keywords ***
Claim Tasks
    ${tasks}=    Get Element Count    css:.claim
    FOR    ${i}    IN RANGE    ${tasks}
        ${present}=    Run Keyword And Return Status    Element Should Be Visible    css:.claim  
        Run Keyword If   ${present}    Run Keywords    Click Element    ${ClaimTask}
        ...    AND    Click Element    ${Missing}
        ...    ELSE    Click Element    ${Continue}
    END

我想在这里做的是计算任务,对于每个任务,点击索赔按钮,一旦点击索赔按钮,点击 ${Missing} 如果它不存在,那么点击 ${继续}。 我尝试了我粘贴的代码,但它不起作用。

有人可以帮我解决这个问题吗?

【问题讨论】:

  • 如果声明存在,您当前的代码将始终尝试点击Missing,如果声明不存在,则只会点击Continue。单击ClaimTask 后,您需要再次检查以查看是否应该单击丢失或继续。

标签: robotframework


【解决方案1】:

如果 ELSE 问题解决了:

*** Keywords ***
User Claims Tasks
        Click Element    ${claim}
        ${continue}=      Run Keyword And Return Status    Element Should Be Visible    ${cont}
        ${missing}=     Run Keyword And Return Status    Element Should Be Visible    ${miss}                   
        Run Keyword If    ${missing}    Click Element    ${miss}
        ...    ELSE IF    ${continue}    Click Element    ${cont}

【讨论】:

  • 您将在 24 小时后接受答复。 ^^
猜你喜欢
  • 1970-01-01
  • 2019-05-01
  • 1970-01-01
  • 2023-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多