|
已经定义了一个tboday,想要通过同行的一个元素a 取得另一个元素b 的值。代码如下:
public String getUBIByMakeValue(String name) {
return listPreconfigVehicle.findElements(By.tagName("tr")).get(getTableSectionIndexByMessage(listPreconfigVehicle.findElement(By.tagName("tr")), name)).findElements(By.tagName("td")).get(1).getText();
}
public static int getTableSectionIndexByMessage(WebElement table,String message){
try {
List<WebElement> rows = table.findElements(By.tagName("tr"));
for(int i = 0; i< rows.size(); i++){
for(int j = 0; j < 5; j++){
if(rows.get(i).findElements(By.tagName("td")).get(j).getText().equals(message)){
return i;
}
}}
throw new NotFoundException("[getTableSectionIndexByMessage] Message: "+message+" , don't exist in table ");
} catch (NoSuchElementException e) {
throw new NoSuchElementException("Table don't exists: " + e.getMessage(), e);
}
}
但最后运行时,总是显示元素a don't exist in table。 急求大神帮忙分析啊 |
|