如何在 Robot Framework 中编写循环 [英] How to write a loop while in Robot Framework

查看:100
本文介绍了如何在 Robot Framework 中编写循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了第一个简单的测试用例,但我遇到了一个问题.

I make my first simple test case, and I have one problem.

是否可以在 Robot Framework 中编写循环?

Is it possible write a loop in Robot Framework?

我想从地址和修改后的变量i"的地址中检索值.我想执行直到存在这样的地址,因为它是表中的一行.

I want to retrieve the value from the address and the address of the modified variable "i". I want to perform until such an address exists, because it is a row in the table.

${f1}       A
${f_temp}   B

While   ${f1} != ${f_temp}
or
While element xpath=//${i} is visible


  ${F_temp}                Get Text     xpath=//${i}
  ${i}                     ${i}+1
  Run Keyword And Continue On Failure   Should be equal  ${f_temp}  ${f1}

有什么想法吗?

推荐答案

Robot Framework 没有 while 循环.您必须使用 FOR 循环和exit for loop if";关键字退出.它将在有限时间内运行,但如果您在范围内选择足够大的数字,它对于实际用途来说已经足够接近了.

Robot Framework does not have a while loop. You must use the FOR-loop and "exit for loop if" keywords to exit. It will run in a finite time, but if you select a large enough number in range, it is close enough for practical purposes.

*** Test Cases ***
For Test
    FOR    ${i}    IN RANGE    999999
           Exit For Loop If    ${i} == 9
           Log    ${i}
    END
    Log    Exited

这篇关于如何在 Robot Framework 中编写循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆