protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Is there a ElementArrayFinder.prototype.filter function for Non-Angular pages

Open sakshisingla opened this issue 12 years ago • 3 comments

Please let me know if there exists a ElementArrayFinder.prototype.filter function for elements on Non-Angular pages. If not, is there any alternative method available?

sakshisingla avatar Sep 16 '14 05:09 sakshisingla

Turn off the browser synchronisation. browser.ignoreSynchronization = true;

smahalingam avatar Sep 16 '14 11:09 smahalingam

You'll need to drop down into vanilla selenium if you're looking to use protractor for non-angular pages.

For that you could use something like this:

var filter = function (selector, filterFn) {
  var filtered = [];
  return selector.then(function (selectorElements) {
    selectorElements.forEach(function (selectorElement) {
      if (filterFn(selectorElement).then === undefined) {
        if (filterFn(selectorElement)) {
          filtered.push(selectorElement)
        }
      } else {
        filterFn(selectortElement).then(function (result) {
          if (result) {
            filtered.push(selectorElement);
          }
        });
      }
    });
    return filtered;
  }
};

You could also reference the source code and adapt it to your liking.

Droogans avatar Sep 16 '14 17:09 Droogans

Either of these should work. Thanks @smahalingam and @Droogans

juliemr avatar Sep 19 '14 22:09 juliemr