I have two links in pageA. when I click the 1st link it redirects to another page called pageB and do some certain jobs and returns back to pageA. From here it should again click to the 2nd link but instead it says page has reloaded and no cache available.
//List of all tickets
for(WebElement ticket: ticketList){
List<WebElement> ticketCells = ticket.findElements(By.tagName('td'));
if(ticketCells.get(4).getText().equalIgnoreCase("Some Text")){
ticketCells.get(2).click(); //Redirects to pageB
.....
do some job
.......
//Finally clicking on the 'SAVE & BACK' button which should return to previous
//page and pick the 2nd ticket from the list of all tickets (1st for loop)
driver.findElement(By.id("save&back")).click();
}
}
Here though it it is going back to previous page pageA but unable to pick the 2nd element from for loop for next operation.
Any thoughts on how to make it work.
ticketwill probably (you haven't mentioned an error message) fail with aStaleElementReferenceExceptionsince you've altered the page contents due to navigation. When navigating back (currently it's unclear whether this exception or the navigation is your problem) the elements in that list can't be interacted with. You have to select them again after navigating and use a counter variable instead of an iterator (determine there are N rows and count from 0..N-1 and doticketList.get(index)). Please add the exception you get.