在robotframework(pythonselenium)中,if语句下的语句没有被执行。

huangapple go评论65阅读模式
英文:

statements under if are not getting executed in robotframework(pythonselenium)

问题

"${elementvisibity}= Run Keyword And Return Status Element Should Be Enabled ${loc_ddlRatePlan}
IF ${elementvisibity} == 'True'
Wait Until Element Is Enabled ${loc_ddlRatePlan}

variable status is been returned as true but wait statement inside if is not getting executed

should execute statements under if"

英文:
${elementvisibity}=    Run Keyword And Return Status    Element Should Be Enabled    ${loc_ddlRatePlan}           
        IF    ${elementvisibity} == 'True'
            Wait Until Element Is Enabled    ${loc_ddlRatePlan}

variable status is been returned as true but wait statement inside if is not getting executed

should execute statements under if

答案1

得分: 1

Run Keyword And Return Status 关键字返回一个布尔值 True 或 False。您的代码针对字符串 True 或 False 进行检查。以下是正确的方法:

Element Visibility
    ${elementvisibity}=   Run Keyword And Return Status    No Operation
    ${valueType}=         Evaluate    type(${elementvisibity})
    Log                   ${valueType}
    IF    ${elementvisibity} == ${TRUE}
        Log    True
    END
英文:

Run Keyword And Return Status keyword returns a boolean True or False. Your code makes a check against the string True or False. Here is the correct way:

Element Visibility
    ${elementvisibity}=   Run Keyword And Return Status    No Operation
    ${valueType}=         Evaluate    type(${elementvisibity})
    Log                   ${valueType}
    IF    ${elementvisibity} == ${TRUE}
            Log    True
    END

huangapple
  • 本文由 发表于 2023年6月6日 14:07:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76411831.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定