[英]Loop through all list items in an unordered list in robotframework
Hi i am trying to loop through an ul and click on all li.嗨,我正在尝试遍历 ul 并单击所有 li。 How would i go about this in robotframework?
我将如何在机器人框架中解决这个问题?
Help is welcome!欢迎帮助!
the html is as follows: html如下:
<ul class="list" tabindex="-1" id="thelist">
<li class="item"></li>
<li class="item"></li>
<li class="item"></li>
</ul>
code:代码:
@{elements}= Get WebElements xpath://*[@id="thelist"]/div[1]/ul
FOR ${element} IN @{elements}
click element ${element}
END
You are already at the <ul>
level (and there is no <div>
), so your code can be:您已经处于
<ul>
级别(并且没有<div>
),因此您的代码可以是:
@{elements}= Get WebElements xpath://ul[@id="thelist"]/li
FOR ${element} IN @{elements}
click element ${element}
END
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.