我想从第二列值中选择表格中的特定元素(我删除了呈现的空白处),并且在找到该元素后,我想单击它(回报是真实的)。我试过这个,但它没有点击它,但只是找到了元素。TypeError:无法调用未定义的方法'点击'
该字段我想选择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>
从量角器的选择命令是:
var deferred = protractorData.p.promise.defer();
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;
});
}).then(function(elem) {
deferred.fulfill(elem[0]);
});
return deferred.promise;
}
我收到以下错误:
TypeError: Cannot call method 'click' of undefined.
能否请您添加与您的代码的jsfiddle它会很容易调试;)在您尝试单击该元素似乎第一种观点不被显示。 – Radu
@Radu,Protractor是一个node.js模块,它不会在JSFiddle中运行。 –
你可以添加你的代码来点击元素吗?我想你是试图点击返回的承诺,而不是返回的元素。 –