在下表中,我想点击我使用量角器通过我的测试脚本收到的第一封电子邮件或第一个推特帖子。
我可以使用ng-repeat遍历行,但是如何使用ng-if识别/区分twitter / email元素并单击第一个元素。请帮忙。
<tr class="ng-scope" ng-class="{selected: message.channel_message_ID === selectedMessageID}" style="cursor: pointer;" pagination-id="messageList" ng-click="showMessageDetails(message);setSelectedMessageId(message.channel_message_ID,message.message_status);" ng-repeat="message in messageList | filter: message_status |filter: search | orderBy: '-date_time' | itemsPerPage: pageSize : ''">
<td class="center" data-title="Status">
</td>
<td class="center" data-title="Source">
<!-- ngIf: message.channel == 'Twitter' -->
<!-- ngIf: message.channel == 'facebook' -->
<!-- ngIf: message.channel == 'Email' -->
<div class="ng-scope" ng-if="message.channel == 'Email'">
</div>
</td>
<td class="center" data-title="Source">
<td data-title="Sender">
<td data-title="Receiver">
</tr>
<tr class="ng-scope" ng-class="{selected: message.channel_message_ID === selectedMessageID}" style="cursor: pointer;" pagination-id="messageList" ng-click="showMessageDetails(message);setSelectedMessageId(message.channel_message_ID,message.message_status);" ng-repeat="message in messageList | filter: message_status |filter: search | orderBy: '-date_time' | itemsPerPage: pageSize : ''">
<td class="center" data-title="Status">
<td class="center" data-title="Source">
<!-- ngIf: message.channel == 'Twitter' -->
<div class="ng-scope" ng-if="message.channel == 'Twitter'">
<div>
<span class="fa fa-twitter icondColor"/>
</div>
</div>
</td>
<td data-title="Sender">
<td data-title="Receiver">
</tr>
&#13;
请帮我点击第一个Email元素或第一个确定的twitter元素。(动态元素)
答案 0 :(得分:0)
您可以在每个元素上应用getAttribute()。您可以使用以下代码:
element.all(by.repeater()).each(function(ele){
ele.getAttribute('ng-if').then(function(eAttrValue){
console.log("ele attribute value is: "+eAttrValue);
if(eAttrValue.indexOf("Email")>=-1){
ele.click();//click if ele is Email only
}
});
});