这里我想要row5,row6,row7的平均值,然后我想用另一个表检查计算是对还是错。怎么做到这一点?
for(WebElement rowElement:TotalRowCount)
{
List<WebElement> TotalColumnCount=rowElement.findElements(By.xpath("td/span"));
int ColumnIndex=1;
for(WebElement colElement:TotalColumnCount)
{
String s=colElement.getText().replace("%", "").replace(",","");
if(!s.isEmpty()&&!s.equals("NA"))
{
if(s.contains(".")||s.contains("-"))
{
double d=Double.parseDouble(s);
System.out.println("Row "+RowIndex+"Double value is"+d);
}
else
{
int x1=Integer.parseInt(s);
System.out.println("Row "+RowIndex+"Integer value"+x1);
}
ColumnIndex=ColumnIndex+1;
}
else{/*do nothing*/}
}
RowIndex=RowIndex+1;
}
输出:
Row 5Integer value140
Row 6Integer value51
Row 6Integer value52
Row 6Integer value51
Row 6Integer value36
Row 7Double value is30.0
Row 7Double value is30.65
Row 7Double value is29.38