Currently utilizing protractor, my aim is to iterate through a collection of locators (each with unique identifiers) in order to retrieve the displayed text and then compare it against an array of expected values.
I have encountered examples similar to the following:
var expected = ['expect1', 'expect2', 'expect3'];
var els = element.all(by.css('selector'));
for (var i = 0; i < expected.length; ++i) {
expect(els.get(i).getText()).toEqual(expected[i]);
}
This allows for comparison against children of a specific locator, but not across multiple locators.
How could I modify the above example to loop through a list of different locators as shown below, and then compare them to respective values from another array?
const locators = {
emp: by.id('employmentError'),
occ: by.id('occupationError'),
stat: by.id('statError'),
show: by.id('showError')
};
The comparison itself seems straightforward, but figuring out how to populate the initial array with text from various locators is the challenge I'm facing.