实际上,我在robot框架中使用了很多if语句,它们很容易成为switch语句。 我在robot框架中找不到任何switch语句的示例(它是否存在?)。 这是我代码的一部分:(在我的代码中,像这样的if语句有50多个可能性,它非常大,日志太大,无法找到信息片段(所有的if都写在日志文件中,甚至那些false)。 谢谢你的帮助
# 1st posibility
\ ${varA} Run Keyword And Continue On Failure Run Keyword If '${Type}' == 'Deal' keyword1 ${Name}
# 2d posibility
\ ${varB} Run Keyword And Continue On Failure Run Keyword If '${Type}' == 'Scenario' and '${varA}' != 'None' keyword2 ${Name}
# 3rd posibility
\ ${varC} Run Keyword And Continue On Failure Run Keyword If '${Type}' == 'Site' and '${varA}' != 'None' keyword3 ${Name}
# 4th posibility
\ Run Keyword And Continue On Failure Run Keyword If '${Type}' == 'SiteFile' and '${varA}' != 'None' keyword4 ${varA}
如果在所有情况下,您都根据单个值(即
${Type}
)决定要执行的关键字,那么您可以尝试使用type=keyword
之类的映射创建字典,并动态找出要执行的关键字。下面是一个简单的例子:和日志:
这就是我所做的
我的日志不清晰
相关问题 更多 >
编程相关推荐