Passing Protractor ElementFinder to deferred.fulfill() results in a promise containing a null value

后端 未结 1 1683
礼貌的吻别
礼貌的吻别 2021-01-21 11:18

I am calling deferred.fulfill() with a Protractor elementfinder as a parameter. When placing a breakpoint on the fulfill I can see that the elementfinder \"solutionElement\" is

1条回答
  •  無奈伤痛
    2021-01-21 11:24

    I usually use the map, filter, action/assert pattern. It looks something like this:

    element.all(locator).map(function(elm, index) {
      // Get the value you are interested in finding and return the element too.
      return {
        elm: elm,
        text: elm.getText(),
        index: index
      };
    }).then(function(list) {
      // Find your text here. Otherwise fail.
      for(var i = 0; i

    Map will fully resolve all the promises before the results are passed to the next then in the chain.

    0 讨论(0)
提交回复
热议问题