0
我想通过它的aria标签获得ng-repeater元素,但想单击此repeater元素的相应不同标签。我怎样才能做到这一点使用过滤器。如何用ng-repeater使用量角器滤波器返回元素的索引
Web Page:
<workspace-group-handler ng-if="!inputCache.search" ng-repeat="group in groups" group="group" class=""><!---->
<!----><workspace-tile tabindex="0" aria-label="Test" edit-mode="$ctrl.editMode" workspace="$ctrl.group" ng-if="$ctrl.group.type === 'workspace' &&
<div class="tile" ng-class="{'selected-tile': isSelected}" ng-click="openWorkspace($ctrl.workspace); $ctrl.toggleSelected($ctrl.workspace)" ng-right-click="toggleDropdown($event)" aria-haspopup="true" dnd-draggable="$ctrl.workspace" dnd-dragstart="$ctrl.notifyDragstart()" dnd-dragend="$ctrl.notifyDragend()" role="button" tabindex="0" draggable="true">
<div class="ws-icon">
我尝试以下操作:
this.AllWorkspace = element.all(by.repeater('group in groups'));
this.WSLabel = this.AllWorkspace.all(by.css('workspace-tile'));
this.WSIcon = this.AllWorkspace.all(by.css('div .ws-icon'));
WSLabel.filter(function(elem, index) {
return elem.getAttribute("aria-label").then(function(text) {
return text.toUppercase() === 'TEST', index; //want to return index and element both not sure how to do this
});
}).then(function(filteredElements, index) {
console.log("Workspace Name found click on it");
this.WSIcon.get(index).click();
});
我怎样才能返回使用滤芯的指数?基于文本匹配,我想获得这个元素的索引,并希望使用相同的索引来点击另一个元素。
在css选择器中需要有一个空格 - 'div .ws-icon'。代替然后索引你可以使用.first()。element ..... – Grasshopper
抱歉在我的代码中输入错误,但这不是我想要解决的实际问题,我已经修改了我的问题请扔掉它再次。 – ssharma