首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Robotframework If条件

Robotframework If条件
EN

Stack Overflow用户
提问于 2015-10-28 13:56:48
回答 1查看 80关注 0票数 0

当我运行这段代码时,它显示${month} not found,${month status}返回True

代码语言:javascript
复制
${month status}=    Run Keyword and Return Status    Element Should Be Visible    xpath=//div[@data-title='Cost for Month']
    Run Keyword If    '${month status}' == 'True'
    ...    ${month}=    Get Text    xpath=//div[@data-title='Cost for Month']    
    ...    Log    Dashboard is displaying ${month} Cost Usage for month Text
    ...    ELSE
    ...    Fail    Cost Dashboard is not displaying Cost Usage for month Text
EN

回答 1

Stack Overflow用户

发布于 2016-01-08 23:35:58

代码语言:javascript
复制
${month status}=    Run Keyword and Return Status    Element Should Be Visible    xpath=//div[@data-title='Cost for Month']
${month}=    Run Keyword If    '${month status}' == 'True'  Get Text    xpath=//div[@data-title='Cost for Month']    
Run Keyword If    '${month status}' == 'True'  Log    Dashboard is displaying ${month} Cost Usage for month Text

Run Keyword If    '${month status}' == 'False'  Fail    Cost Dashboard is not displaying Cost Usage for month Text

有点粗糙的解决方案,但我们也遇到了这种情况,并使用上面的修复程序解决了它。

我认为您的代码失败是因为${month}被解释为关键字而不是变量。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33383880

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档