I am trying to traverse through a table using Selenium in Java (currently using the chromedriver). The content of the table consists of different people with links to their profiles, for each person in that table I will go into their profile and extract some information. This I will do for X amount of people. The table contains 5 people per page and I navigate the pages by clicking a pagination button ">". See https://www.seleniumeasy.com/test/table-pagination-demo.html for how the structure of the table looks like.
Now to the issue: So, as an example, I am currently at exampleUrl.com/page_containing_table I then enter a user's profile and extract their information, their URL being something like exampleUrl.com/user_x. I then use
driver.navigate().back();
to come back to the table page (exampleUrl.com/page_containing_table).
The problem is that when I traverse through the table, the URL does not change. So whenever I go back from exampleUrl.com/user_x to exampleUrl.com/page_containing_table, I will always end up at the first page of the table.
This works fine when I only need to get user information from the first page in the table, but what if I need to go through 25 pages? If I am at page 11, then I would be able to retrieve the information of one user at page 11 and then I would navigate back to page 1, I would then have to paginate to page 11 again just to be able to extract one more user's information.
What I tried:
I tried to just paginate all the pages to retrieve the links of all the user's to then click them but then I obviously receive the
StaleElementReferenceExceptionbecause that link is currently not visible on the page.I also thought that maybe there was a way to replicate the driver whenever I paginated the table and then switch to that specific driver but that also failed.
Through Google I haven't been able to find any other questions regarding this so I am a bit at a loss. Is there a way to somehow save the state so I won't have to go back to the first page every time?
Thanks in advance :)