I have a total of 200 users. I have one angular page which has showed 20 users on the present page. Now, I want to find a random user which is in any next pages. I have page navigator button on the angular page. How can I achieve through automation in protractor?
What you can do is write a loop, that checks:
- Is the user on the page?
- No, then click on next page
- Yes, quit loop and record user element
- Throw error if after last page the user is not found
This might be very slow, but end2end tests can only do what users can, they cannot do magic. Unless you ask the developers to build in the magic. For example find the users by adding it to the URL. Sometimes to make testing easier I think it is ok if the team builds a shortcut in the application to get to a certain point. So that not every test case has to go through the loop for example. You might only need one test to test the paging system, you don't want every test to do that.