如何通过文本[量角器]在ng-table中查找特定行 [英] How to find specific row in ng-table by text [protractor]
问题描述
我想通过第二列值从表中选择特定元素(我删除了渲染的空格),然后找到该元素之后我想点击它。 (返回true)
我试过这个,但它没有点击它,它只是找到元素。
I want to select specific element from a table by the second column value (I removed the whitespaces that where rendered), and after that element is found I want to click on it. (the return in true) I've tried this, but it doesn't click on it, it just finds the element.
html代码我想要选择的是以下内容:
The html code for that filed I want to select is the following:
<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>
量角器的select命令是:
The select command from protractor is:
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();
量角器是一个基于Selenium的框架,用于角度js自动化测试。即使是基于Selenium的解决方案也可以工作...
Protractor is a framework based on Selenium made for angular js automated testing. Even a solution based on Selenium may work...
推荐答案
您应该在尝试点击它们之前返回已过滤的元素我猜。这是如何 -
You should return the filtered elements before trying to click on them i guess. Here's how -
element.all(by.repeater('item in $data track by $index')).filter(function(row) {
return row.getText().then(function(txt) {
txt = txt.replace(/\s/g, '');
var found = txt.split('ID0001');
return found.length > 1;
});
}).then(function(elem){
elem[0].click();
});
希望这有帮助。
这篇关于如何通过文本[量角器]在ng-table中查找特定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!