如何将HTML表中的元素转换成Robot框架中的ArrayList元素

2024-05-20 16:44:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试获取HTML表值的元素,并尝试将其拆分为ArrayList元素(行)示例:

  • 我需要获取@{xpath\u location}[2]的文本
  • 我需要单击@{xpath\u location}[5]的元素

enter image description here

我曾经得到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.

我通过“get table cell”获取元素,然后我可以获取值的字符串,但我不能选中此表中的复选框(第6列)。你知道吗


Tags: 文本元素示例sessionhtmlseleniumlocationfirefox
1条回答
网友
1楼 · 发布于 2024-05-20 16:44:53

最后,我知道如何通过xpath的Set变量选择复选框:

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}

相关问题 更多 >