我使用下面的代码来获取表中的所有行,但我只想要最后一行数据
WebElement webtable=driver.findElement(By.id("requisitionsTable"));
List <WebElement> rowCollection=webtable.findElements(By.xpath("//*[@id='requisitionsTable']/tbody/tr"));
System.out.println("No. of Rows in the WebTable: "+rowCollection.size());
for(WebElement rowElement:rowCollection)
{
System.out.println("rowElement"+rowElement.getText());
List<WebElement> colCollection=rowElement.findElements(By.xpath("td"));
for(WebElement colElement:colCollection)
{
System.out.print(colElement.getText());
System.out.print(" ");
}
System.out.println("");
}
答案 0 :(得分:0)
使用下面的cssSelector获取最后一行数据。
app.get('/:trial', function(req, res){
var trial = req.params.trial;
trial.find(function(err, records) {
if (err)
res.send(err);
res.json(records); // returns all trial records in JSON format
});
});