首页 > 解决方案 > 如果满足相应条件,如何记录两条消息中的任何一条

问题描述

我的代码看起来像:

${tempclosed}   ${value}=   Run Keyword And Ignore Error    Element Should Not Be Visible   ${orderonline}

Run Keyword If  '${tempclosed}' == 'TRUE'   log Store is Closed on Zomato Or is Temporarily Closed  Element Should Be Visible   ${overview}

Sleep   3s

Run Keyword Unless  '${tempclosed}' == 'FALSE'  log Store is Open on Zomato 

“如果在 GUI 上找到 ${tempclosed} 元素,我希望将消息记录为“Zomato 上的商店已关闭或暂时关闭”,如果未找到 ${tempclosed} 元素,则记录“Zomato 上的商店已打开” ,考虑到测试应该继续通过“

我得到的当前输出是:在这两种情况下,它都会记录第二条消息“Store is Open on Zomato”。

找到该元素时如何记录第一条消息?

标签: seleniumif-statementrobotframework

解决方案


log Store is Closed on Zomato Or is Temporarily Closed  Element Should Be Visible   ${overview}

我认为即使您有正确的条件(通过/失败),这也不起作用,因为似乎有两个关键字和后一个关键字的参数: - Log 后面没有两个空格,或者这log Store is Closed on Zomato Or is Temporarily Closed真的是一个关键字?- 你打算Element Should Be VisibleELSE语句中执行吗?那么应该...log Store is Closed on Zomato Or is Temporarily Closed ELSE Element Should Be Visible ${overview}


推荐阅读