1

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?

  • 1
    How would an end user find that user? Presumably either some kind of search or by clicking e.g. "next" until they see it. So have you tried simulating that? What happened? – jonrsharpe Mar 6 at 8:19
  • Yes. but, I want to make whole this scenario dynamically not in a static way. Otherwise, it's very easy by presumably on which page the user is created. – Viren Rakholiya Mar 12 at 8:25
2

You can't.

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.

  • 1
    To add to this, there may be ways to reduce the number of pages you need to go through. If you know your entire list of users, and the sorting is consistent (e.g. alphabetical A-Z), you could predict what page your user should appear on, and go to this page directly if there are pagination numbers, or through URL manipulation if not. This will drastically reduce the amount of time waiting for page loads. – anonygoose Mar 7 at 14:32
  • But, how can I achieve the 1st step and 2nd step respectively in protractor script? I know this algorithm. But, I am not able to solve through automation script! – Viren Rakholiya Mar 12 at 8:21
  • @VirenRakholiya Try to find elements which contain text: stackoverflow.com/questions/32016080/… and if it is not found click the next page button? – Niels van Reijmersdal Mar 12 at 8:25
  • I have already used this function. But, the problem occurs how can I achieve this statement 'if it is not found' in protractor? – Viren Rakholiya Mar 12 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.