How to Store the lastid that i get from the previous screen and fetch that id and click the id in the next tab

Issue

My Scenario:

In the First Form Creating Origin – I enter all the inputs like origin etc and save and on saving

the dynamic id gets generated

Second Screen Creating a Plan for the Origin –

1)In the Create Screen there is a Search option so i search with Origin which was created earlier and map it to the Plan Screen

2)After saving i navigate back to the Grid which has all the Rows added with the Origin information which is mapped to the Plan and also contains the dynamic ids for each origini.

3)I have read the table and clicked on the row which contains the OriginName as "ORIGI" as seen below

List<WebElement> OriginName = driver.findElements(By.xpath("//table[contains(@class,'mat-table')]//tr"));
int countrow = OriginName .size();

        for(WebElement originname:OriginName )
        {
            String text ="//td[contains(normalize-space(),'ORIGI')]";
            
            {
                
                WebElement id = originname.findElement(By.xpath(text));
                        
                id.click();
                break;
            }
        }

and it goes and navigates to the plan screen again and clicks on Send Proposal.

Issue:

The Actual Problem starts from here :

I then have to navigate to the Pending Confirmation section.

This section will have all the ids which has Proposal Sent but is not confirmed.

****The question here is how do i find the id for which the proposal is

accepted by me table.****

Can add more information …Can someone please give inputs…

Solution

You can use hashmap to store and get the data.

Store the id in hashmap

    public class CreateOrigin(){
    
    public static HashMap<String, String> createdValues = new HashMap<String, String>();
    
    public void createOrigin(){
    
    //Code generate id
    
    createdValues.put("id", valueOfNewlyCreatedOrigin);
    
    }
   } 

Get the value from hashmap

public class pendingConfirmationScreen(){

public String idOfOrigin = CreateOrigin.createdValues.get("id");

//Use idOfOrigin value in your code

}

Answered By – Nandan A

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published