I've given an array of elements and need to check that every single text is a number greater than 30. Sample input data:
<ul class="data-list">
<li class="data-item">40</li>
<li class="data-item">31</li>
<li class="data-item">32</li>
<li class="data-item">101</li>
</ul>
Currently, I'm using .each()
function to process every element one by one and then parseInt()
and toBeGreaterThan()
jasmine matcher:
var dataItems = element.all(by.css("ul.data-list > li.data-item"));
dataItems.each(function (elm) {
elm.getText().then(function (text) {
expect(parseInt(text)).toBeGreaterThan(30);
});
});
Is there a simpler or better way to address the problem? Would it be appropriate to first map()
into an array of integers and then apply the matcher to every element of an array?
What I am a bit concerned about in using the current approach is that it would fail at the very first element that is less than or equal to 30 preventing us to see what other values of an array are.