Nar*_*yan 2 java selenium for-loop nested robotframework
我需要在 Robot 框架中创建一个嵌套循环。你能帮我做吗?
${contents}= Get File ${file path}
@{lines}= Split to lines ${contents}
${matched elements}= Get Webelements ${LABEL PORTAIL XPATH }
: FOR ${element} IN @{matched elements}
\ ${text}= Get Text ${element}
\ : FOR ${line} IN @{lines}
\ Run Keyword If '${text}' == '${line}' Log '${text} matched'
Run Code Online (Sandbox Code Playgroud)
我需要有一个嵌套循环,将文件中的所有${text}与所有的进行比较@{lines}。
提前致谢
RF 中没有嵌套循环;这只能通过在外部循环中调用具有内部循环的关键字来完成。
但是,在您的特定情况下,您可以不使用它 - 因为您想匹配整行,这可以通过应该包含:
${contents}= Get File ${file path}
@{lines}= Split to lines ${contents}
${matched elements}= Get Webelements ${LABEL PORTAIL XPATH }
: FOR ${element} IN @{matched elements}
\ ${text}= Get Text ${element}
\ ${present}= Run Keyword And Return Status Should Contain ${lines}
${text}
\ Run Keyword If ${present} Log '${text} matched'
Run Code Online (Sandbox Code Playgroud)
如果您要参加部分比赛 - 即${text}成为${lines}会员的一部分,那么就不可能像这样。
| 归档时间: |
|
| 查看次数: |
10816 次 |
| 最近记录: |