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:
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.