0

I have a simple webtable called branch which has columns id, branchName, BranchLocaction. Ihave to scenarios to add one branch and test if it is correctly added or not. I have the below function which is supposed to give me the latest id before addition and after addition. before addition its invoked properly and gives me the correct row. But afteradding, some times it gives the old id, sometimes correctly new id, sometimes null. Its a definitely wait isssue. I am also calling some customized functions to wait for ajax call/jquery. But still it does not help. Please help me. If you need more detail. PLease let me know

    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);
    }

}
BIswa
  • 1
  • 2
    are you sure the code in the question is javascript? – Jaromanda X Jan 27 '20 at 03:12
  • the codesnippet i have pasted is Java not javascript – BIswa Jan 27 '20 at 06:26
  • so why, if the code you are having an issue with is Java, have you tagged this question with Javascript, and not Java? There is a difference between the two languages ... One is essentially a toy, designed for writing small pieces of code, and traditionally used and abused by inexperienced programmers. The other is a scripting language for web browsers. – Jaromanda X Jan 27 '20 at 07:09
  • My bad. had to give minimum 5 tags. thats why added javascript. now i have changed it to java. Thanks – BIswa Jan 27 '20 at 08:00

0 Answers0