python - 如何在Robot框架中将元素的html表转换为Arraylist元素
问题描述
我试图获取 HTML 表值的元素并尝试将其拆分为 ArrayList 元素(行)示例:
- 我需要获取 @{xpath_location}[2] 的文本
- 我需要单击 @{xpath_location}[5] 的元素
我曾经获取 Webelements,结果是:
@{Row5} = [ <selenium.webdriver.firefox.webelement.FirefoxWebElement (session="15a5573d-6584-4669-bbce-1b4bf61f3298", element="f175bac9-2f59-4e8b-a24b-2e098aea47a7")> ]
List variable '@{Row5}' has no item in index 2.
我通过“获取表格单元格”获取元素,然后我可以获取值的字符串,但我无法选择此表中的复选框(第 6 列)。
解决方案
最后,我知道如何通过 xpath 的 Set Variable 选择复选框:
Validate Data4Click
[Arguments] ${row}
${CPid}= Get Table Cell ${AddN_C.value_table} ${row} 3
AddnoteChxboxColumn ${row}
[Return] ${CPid}
AddnoteChxboxColumn
[Arguments] ${row}
${xpathAddnote_column}= Set Variable xpath=/html/body/form/table/tbody/tr/td/table[2]/tbody/tr[5]/td/table/tbody/tr/td[2]/table/tbody/tr/td/table[1]/tbody/tr[${row}]/td[6]/input[4]
Validate chkbox has selected ${xpathAddnote_column}
Validate chkbox has selected
[Arguments] ${locate}
Wait Until Element Is Visible ${locate} ${timeout}
Checkbox Should Not Be Selected ${locate}
Select checkbox ${locate}
Checkbox Should Be Selected ${locate}
推荐阅读
- authentication - Auth0 - 不同组织的移动应用程序
- docker - Filebeat 停止向 Logstash 发送数据,因此 Elasticsearch 在几十万个文档后停止发送数据,重新启动 Filebeat 容器
- python - 使用字典计数并删除不相关的值
- metadata - Shibboleth SP 配置异常 shibboleth 处理程序在未配置的位置调用 (http://Shub.adatum.com/Shibboleth.sso/login)
- javascript - 如何使用 jQuery 选择仅包含空格的元素?
- javascript - 如果键具有特定元素,则不显示组件
- python - pypfopt (PyPortfolioOpt) 库 从每周回报计算年化预期回报
- kubernetes - 通过秘密文件在 Kubernetes 中使用变量
- reactjs - reactjs下拉父菜单路由不起作用
- php - 用于在 php 中提取 db 数据的嵌套 while 循环