Table Class
public class Table {
private WebElement table;
public Table(WebElement table) {
super();
this.table = table;
}
public WebElement getTable() {
return table;
}
public void setTable(WebElement table) {
this.table = table;
}
/**
* 获取表格行的集合
* @return
*/
public List<WebElement> getRows(){
List<WebElement> rows = table.findElements(By.tagName("tr"));
return rows;
}
/**
* 获取表格某行的列集合
*/
public List<WebElement> getColumns(int rowNum){
List<WebElement> rows = getRows();
List<WebElement> cols = rows.get(rowNum-1).findElements(By.tagName("td"));
return cols;
}
/**
* 获取某行某列单元格元素
*/
public WebElement getCell(int rowNum,int colNum){
return getColumns(rowNum).get(colNum-1);
}
/**
* 获取某行某列的单元格中 元素
*/
public WebElement getElement(int rowNum,int colNum,By by){
return getCell(rowNum, colNum).findElement(by);
}
}