【发布时间】:2013-06-08 13:54:21
【问题描述】:
我正在尝试单击表格中的复选框。我搜索表格,当我在第二列中找到正确的信息时,我想单击该行第一列中的复选框
public WebDriver searchSelectStore(WebDriver dr1, String srchTable, String srchFor) {
// Grab the table
WebElement table = dr1.findElement(By.id(srchTable));
// Now get all the TR elements from the table
List<WebElement> allRows = table.findElements(By.tagName("tr"));
// And iterate over them, getting the cells
for (WebElement row : allRows) {
List<WebElement> cells = row.findElements(By.tagName("td"));
for (WebElement cell : cells) {
//
if(cell.getText().equals(srchFor)){
System.out.println(row.getText());
// here I need to click on the first column of that row
}
}
【问题讨论】:
标签: java selenium select checkbox html-table