我需要在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'
我需要一个嵌套循环,将所有${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'
如果你正在进行部分匹配 – 即${text}成为${lines}成员的一部分,那么就不可能这样.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。