首先需要获取table的行数和列数,通过For循环进行遍历获取。
但是RF本身并不支持直接使用双层循环,需要把嵌套的循环提取为关键字。
如下图表格
*** Test Cases ***
Test
- ${value} get table
log to console ${value}
*** Keywords ***
****get table list
- ${rows} Get Element Count ${WEB_ROW} #获取总行数
${cells} Get Element Count ${WEB_CELL} #获取总列数
${table_list} = Create List
FOR ${rowIndex} IN RANGE 2 ${rows+2}
${row_list} get cells text ${rowIndex} ${cells}
append to list ${table_list} ${row_list}
END
[Return] ${table_list}
get cells text**
-
[Arguments] ${rowIndex} ${cells}
${row_list} = Create List
FOR ${cellindex} IN RANGE 1 ${cells+1}
c u r T e x t G e t T e x t / / t b o d y / t r [ {curText} Get Text //tbody/tr[ curTextGetText//tbody/tr[{rowindex}]/td[${cellindex}]
append to list ${row_list} ${curText}
END
[Return] ${row_list}