简体   繁体   English

循环遍历robotframework中无序列表中的所有列表项

[英]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.

相关问题 For 循环没有遍历列表中的所有项目 - For loop is not iterating through all of the items in a list 循环浏览字典中嵌入的列表列表中的所有项目 - Loop through all items in a list of list embedded in dictionary 使用 Selenium 提取无序列表中的所有列表项 - Use Selenium to extract all list items in an Unordered list 如何循环遍历列表中的项目不断附加在循环中的列表? - how to loop through a list where the items of the list are constantly appended in the loop? 使用 RobotFrameWork 循环通过 JSON 的 URL 列表以断言每个页面上都存在一个元素 - Loop Through JSON List Of Urls With RobotFrameWork To Assert An Element Exists On Each Page Python:遍历列表但重复一些项目 - Python: Loop through list but repeat some of the items For 循环未捕获 function 列表中的所有项目 - For loop not catching all items in list for function Sphinx 向无序列表项添加段落标签 - Sphinx adding paragraph tags to unordered list items 循环遍历字符串列表并删除特定列表项 (i) 之后的所有项,其中 i 可以是 a 或 b 或 c - Loop through a list of strings and remove all items after a specific list item(i) where i can be a or b or c 此 for 循环不会遍历列表中的所有元素 - This for loop does not iterate through all element in a list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM