Click here to Skip to main content
15,887,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My Scenario:

1)I need to Create a Demand and after creating the Demand the Id will be autogenerated 2)I need to Fetch that id and use it in another screen

Question: While i created the Demand and try to fetch the Id there will be multiple users who will create the Demand at the same time and there will be multiple ids which will get generated. So i need to get only the Id which i have got after creating the Demand . How Do i handle this ....

So Far i have treid to fetch the lastestid only by using HashMap and it should not be done that ways.

What I have tried:

My Code which i have used to Fetch the id is:
Java
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();

    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, .SearchInputXpath , createdValue.put("latestDataId", latestId.getText()));

    



}

The above code will only Fetch the latestid but as specified i need to get only the Id for which i have created the Demand and should not fetch the id of a Demand created by someone else.
Posted
Updated 10-Sep-21 3:50am
v2

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