【问题标题】:How to convert html table of element to Arraylist element in Robot framework如何在Robot框架中将元素的html表转换为Arraylist元素
【发布时间】:2019-12-21 15:16:17
【问题描述】:

我曾尝试获取 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 列)中的复选框。

【问题讨论】:

    标签: python arraylist robotframework


    【解决方案1】:

    最后,我知道如何通过 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}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-08
      • 2011-02-13
      • 2011-10-30
      • 2018-12-20
      • 1970-01-01
      • 2021-09-26
      相关资源
      最近更新 更多