The Problem:
I have an array of promises which is resolved to an array of strings. Now the test should pass if at least one of the strings matc
If those [text1, text2, text3] is texts from ElementFinder .getText()
then you can also to try with Expected Conditions (You know that i am huge fan of EC right? :) ).
describe('test', function () {
it('test', function () {
var EC = protractor.ExpectedConditions;
browser.get('http://www.protractortest.org/testapp/ng1/#/form');
var textToContain = 'Check'; //Notice, that this is not 'equals', this is 'contains'
var elementTextToCheck1 = EC.textToBePresentInElement($('#checkboxes h4'), textToContain); // Here it will be true : Checkboxes
var elementTextToCheck2 = EC.textToBePresentInElement($('#animals h4'), textToContain); //false
var elementTextToCheck3 = EC.textToBePresentInElement($('#transformedtext h4'), textToContain); //false
var oneElementShouldContainText = EC.or(elementTextToCheck1, elementTextToCheck2, elementTextToCheck3);
expect(oneElementShouldContainText()).toBeTruthy(`At least one element should contain "${textToContain}"`);
})
});
For simple elements: http://www.protractortest.org/#/api?view=ExpectedConditions.prototype.textToBePresentInElement
For textArea, inputs: http://www.protractortest.org/#/api?view=ExpectedConditions.prototype.textToBePresentInElementValue
Notice, that unfortunatelly .textToBePresentInElement works only with single ElementFinder, ArrayElementFinder is not supported. But in that case you can make something with .filter()
and assert that returned list is empty.