Click here to Skip to main content
15,749,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My Scenario : I have a Table as seen in the below screen shot where there is a Search Demand box. I have a method which fetches the LatestDemand Id and then enters the Demand Id in the Search box and then i click on the checkbox to select the Demand Id .Then i Clear the Demand Id that is entered in the Search Demand text box and my next requirement is to fetch the next Id from the table. Any Leads
The Issue is it Fetches the Lastest Id which is 4251 and clicks on the checkbox but iam not able to fetch the other Id which is 4152.

What I have tried:

Below is the Code to Fetch the Id : The first time it fetches the id the second time it is not fetching the Id ...

public static HashMap<String, String> createdValue; 

public static void FetchID(WebDriver driver) throws InterruptedException{
    createdValue = new HashMap<String, String>();
    List<WebElement> tableValues = driver.findElements(By.xpath("//table//tr//td[contains(@class,'mat-column-demandId')]//span"));

    int tableValueSize = tableValues.size();

    for(int i =0;i<tableValueSize;i++){
        WebElement latestId = driver.findElement(By.xpath("(//table//tr//td[contains(@class,'mat-column-demandId')]//span)["+ tableValueSize +"]"));
        createdValue.put("latestDataId", latestId.getText()); 

        System.out.println(createdValue.put("latestDataId", latestId.getText()));

        inputEntry(driver, AppXPathsConstants.SearchInputXpath , createdValue.put("latestDataId", latestId.getText()));

        clickOnElement(driver, AppXPathsConstants.PlanningcheckboxselectionXpath);

        WebElement SearchinputElem = driver.findElement(By.xpath("//input[contains(@class,'search-class')]"));

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900