0

我有一个名为 branch 的简单 webtable,其中包含 id、branchName、BranchLocaction 列。我必须在场景中添加一个分支并测试它是否正确添加。我有以下功能,它应该在添加之前和之后给我最新的 id。在添加之前正确调用它并给我正确的行。但是添加后,有时它会给出旧的 id,有时是正确的新 id,有时是 null。这绝对是一个等待问题。我还调用了一些自定义函数来等待 ajax 调用/jquery。但它仍然没有帮助。请帮我。如果您需要更多详细信息。请告诉我

    public int getlatestBranchtID() throws InterruptedException
{


    int totalnoOfrows = driver.findElements(By.xpath("//table[@class='table table-striped']/tbody/tr")).size();
    System.out.println(totalnoOfrows);
    if (totalnoOfrows == 0)
    {
        return Integer.parseInt("0");
    }
    else{
        String latestBranchID= driver.findElements(By.xpath("//table[@class='table table-striped']/tbody/tr/td[1]")).get(totalnoOfrows-1).getText();
        System.out.println("latest branch id is" + latestBranchID);
        return Integer.parseInt(latestBranchID);
    }

}
4

0 回答 0