I'm looking for some advice on how to select a List.When I click a button that creates a new 'page', the given value is dynamic, in that it is totally random and not sequential. I would expect it to follow something like: page 1 = 0, page 2 = 1, page 3 = 2, etc.
By default I begin with a page. Although when I trigger a button to create new pages the values appear as follows:

New Page New Page 2 New Page 3 New Page 4 So when I attempt to use the following:

List option = chrome.findElements(By.tagName("option")); option.get(0).click(); option.get(1).click(); option.get(0).click();It's obviously failing as the values are c277, c346 etc etc, and there is no way of knowing what the values will be in a new session as they will always be different.
The stacktrace is throwing a StaleElementReferenceException because its not in the DOM.
How can I select each page when the values are completely random?
I'm using Webdriver and JUnit4.


Check Solution