量角器by.repeater如何找到兄弟元素

时间:2014-07-02 21:08:30

标签: protractor

我想通过class="dropdown-item-icon ctp-img-notification-error"

获取图标出错的所有元素的文本(不希望带有警告的元素)

我怎么能得到它?

在这种情况下,我只希望文字“无法加载数据”,因为这是一个错误

<li ng-repeat="option in options" class="dropdown-item ng-scope">
  <a href ng-class="{ selected : isSelected(option)}" ng-click="selectItem(option)">
    <div data-ng-if="option.iconCls" class=ng-scope">
      <div class="dropdown-item-icon ctp-img-notification-error" data-ng-class="options.iconCls"></div>
      <div class="ng-binding">unable to load Data</div>
    </div>
  </a>
  <a href ng-class="{ selected : isSelected(option)}" ng-click="selectItem(option)">
    <div data-ng-if="option.iconCls" class=ng-scope">
      <div class="dropdown-item-icon ctp-img-notification-warning" data-ng-class="options.iconCls"></div>
      <div class="ng-binding">using cache Data</div>
    </div>
  </a>
</li>

1 个答案:

答案 0 :(得分:0)

我的第一个想法是这样的:

var errorMessages = [];

element.all(by.css('.dropdown-item-icon.ctp-img-notification-error .ng-binding')).then(function(items) {
  items.forEach(function(item) {
    item.getText().then(function(message) {
      errorMessages.push(message);
    });
  }); 
});