In one of the tests, we need to assert that one of the 3 elements is present. Currently we are doing it using the protractor.promise.all()
and Array.reduce()
:
var title = element(by.id("title")),
summary = element(by.id("summary")),
description = element(by.id("description"));
protractor.promise.all([
title.isPresent(),
summary.isPresent(),
description.isPresent()
]).then(function (arrExists) {
expect(arrExists.reduce(function(a,b) { return a || b; })).toBe(true);
});
Is there a better way to solve it with Jasmine without resolving the promises explicitly? Would we need a custom matcher or it is possible to solve with the built-in matchers?
Check this:
Notice that i am executing function that ExpectedCondition returns - so i am getting result of that function(Promise that will be resolved to boolean) instead of function.
You can use .presenceOf() if you need it instead .visibilityOf()
http://www.protractortest.org/#/api?view=ExpectedConditions.prototype.or
You could simply get all the elements with a single selector and assert that the count is superior to zero: