如何使用Page Object文件中的函数在将索引传递给函数时为转发器中的特定索引元素。
this.IncList = element.all(by.repeater("incident in $ctrl.allIncidents"));
this.Inc2ndElement = this.IncList.get(1);
如何将它放在函数中,以便每次将Index值传递给function时,都会返回该索引处的元素。
答案 0 :(得分:1)
您可以将其放入函数传递参数 -
this.IncList = element.all(by.repeater("incident in $ctrl.allIncidents"));
this.Inc2ndElement = function(i) {
return this.IncList.get(i);
};
this.Inc2ndElement(2); // gets the element at index 2
答案 1 :(得分:0)
我有一个复杂的场景,其中在转发器中有转发器,因此我想通过父转发器和子转发器的索引来获取元素,我可以通过以下方式实现: 面板属性页面:
this.getTimeLine = function(IncId,TimelineId){
this.IncTimeLine = this.IncList.get(IncId).all(by.repeater("event in $ctrl.timeline.filterBy"));
this.IncTopTimeLine = this.IncTimeLine.get(TimelineId);
this.IncTopTimeLineTime = this.IncTopTimeLine.all(by.css('span.timeline__time'));
return this.IncTopTimeLineTime;
};
通话功能:
var TimeLine = Panel.getTimeLine(IncId, TimelineId);