How can a protractor test verify the location and order of text on page? Our application generates schedules that is comprised of divs in specific orders depending on the date/time and type of activity.

I know the text itself can be verified but am not sure how to verify that they are in the correct order.

Ex: A needs to appear before B if C does not exist

1 Answer 1


This is actually pretty convenient to do by calling getText() on an array of elements - this would produce an array of texts which, what important, is ordered the same way as elements are ordered:

var divs = $$(".someCommonDivClass");

expect(divs.getText()).toEqual(["first text", "second text", "third text"]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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