【发布时间】:2015-12-19 07:55:34
【问题描述】:
我想通过第二列值从表中选择特定元素(我删除了呈现的空格),找到该元素后我想点击它。 (返回为真) 我试过这个,但它没有点击它,它只是找到元素。
我要选择的那个文件的 html 代码如下:
<table ng-table="tableParams" id="Panel" class="tbl-option-list" template-pagination="directives/controls/Pager/Pager.html">
<caption translate>Orders</caption>
<tr id="Panel">
<!-- 1 -->
<th class="fixed-width-glyphicon"></th>
<!-- 2 -->
<th translate>Identifier</th>
</tr>
<tr ng-repeat="item in $data track by $index" ng-class="{'active-bg': order.$selected}" ng-click="changeSelection(order, getRowActions(order))">
<!-- 1 -->
<td class="fixed-width-glyphicon">
<div class="fixed-width-glyphicon">
{{item.priority.toUpperCase()[0]}}
</div>
</td>
<!-- 2 -->
<td>{{item.identifierCode}}</td>
</tr>
</table>
量角器的选择命令是:
element.all(by.repeater('item in $data track by $index')).filter(function(row) {
row.getText().then(function(txt) {
txt = txt.replace(/\s/g, '');
var found = txt.split('ID0001');
return found.length > 1;
});
}).click();
Protractor 是一个基于 Selenium 的框架,用于 Angular js 自动化测试。即使是基于 Selenium 的解决方案也可以工作......
【问题讨论】:
-
尝试将
return放在row.getText().then(function(txt) { ...之前。 -
谢谢,但不起作用....
标签: javascript angularjs selenium automated-tests protractor