UI量角器查找和放大器;单击选择框基于文本的搜索 [英] UI Protractor Find & Click Select Box Based On Text Search
本文介绍了UI量角器查找和放大器;单击选择框基于文本的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找到一种方法来搜索具有名为X在它行,然后单击使用UI量角器该行中的复选框。
我一直很成功为止。
如果你看到下面,我想搜索的 testproxy ,然后单击与之相关联的复选框。
< DIV ID =general_section>
&所述p为H.;下面的代理是可以添加到集群< / P>
< DIV CLASS =表响应>
<表ID =proxies_table级=table表条纹表镶上>
<&THEAD GT;
&所述; TR>
百分位><输入类型=复选框NG模型=全选NG点击=selectAllServers(全选)级=NG-原始NG-不变NG-有效>< /第i
百分位RES键=settings.emailProxy.proxy>代理< /第i
< / TR>
< / THEAD>
<&TBODY GT;
!< - ngRepeat:在model.selectedServers服务器|排序依据:'主机' - >< TR NG重复=在model.selectedServers服务器|排序依据:'主机'>
&所述; TD>
<输入类型=复选框NG模型=server.selected级=NG-原始NG-不变NG-有效>
< / TD>
&所述; TD>
testproxy
< / TD>
< / TR>< - 结束ngRepeat:在model.selectedServers服务器|排序依据:'主机' - >< TR NG重复=在model.selectedServers服务器|排序依据:'主机'>
&所述; TD>
<输入类型=复选框NG模型=server.selected级=NG-原始NG-有效NG-感动>
< / TD>
&所述; TD>
testproxy_1
< / TD>
< / TR>< - 结束ngRepeat:在model.selectedServers服务器|排序依据:'主机' - >
< / TBODY>
< /表>
< p =班引NG-隐藏NG-秀=model.selectedServers.length === 0&放大器;放大器;&放大器;放大器; isAdd>无代理< / P>
< p类=引NG-隐藏NG-秀=model.selectedServers.length === 0&放大器;放大器;&放大器;放大器;!isAdd方式>没有代理删除< / P>
< / DIV>
< / DIV>
解决方案
尝试过滤功能,我添加了一些意见,使之成为可读的:
//的每一行使用NG重复的定位器过滤
$$('[NG-重复=在model.selectedServers服务器|排序依据:\\'主机名\\']')。过滤器(功能(富){
//检查在TD文本索引1,又名第二个
返回富。$$('TD')。得到(1).getText()。然后(函数(巴){
//返回它有自己的价值(textproxy)行
返回杆===testproxy
});
//在这里,您可以使用该行的内容与你的价值
//所以你要点击复选框
})。然后(功能(值){
。值[0] $('[类型=复选框])点击();
});
I am trying to find a way to search for the row that has the name X in it and then click on the checkbox in that row using UI Protractor.
I have been very unsuccessful so far.
If you see below, I want to search for testproxy and then click the checkbox associated with it.
<div id="general_section">
<p> The following proxies are available to add to a cluster.</p>
<div class="table-responsive">
<table id="proxies_table" class="table table-striped table-bordered">
<thead>
<tr>
<th><input type="checkbox" ng-model="selectAll" ng-click="selectAllServers(selectAll)" class="ng-pristine ng-untouched ng-valid"></th>
<th res-key="settings.emailProxy.proxy">Proxy</th>
</tr>
</thead>
<tbody>
<!-- ngRepeat: server in model.selectedServers | orderBy:'hostname' --><tr ng-repeat="server in model.selectedServers | orderBy:'hostname'">
<td>
<input type="checkbox" ng-model="server.selected" class="ng-pristine ng-untouched ng-valid">
</td>
<td>
testproxy
</td>
</tr><!-- end ngRepeat: server in model.selectedServers | orderBy:'hostname' --><tr ng-repeat="server in model.selectedServers | orderBy:'hostname'">
<td>
<input type="checkbox" ng-model="server.selected" class="ng-pristine ng-valid ng-touched">
</td>
<td>
testproxy_1
</td>
</tr><!-- end ngRepeat: server in model.selectedServers | orderBy:'hostname' -->
</tbody>
</table>
<p class="lead ng-hide" ng-show="model.selectedServers.length === 0 && isAdd">No available proxies.</p>
<p class="lead ng-hide" ng-show="model.selectedServers.length === 0 && !isAdd">There are no proxies to remove.</p>
</div>
</div>
解决方案
Try a filter function, I've added some comments to make it a readable:
//filter through each row using the ng-repeat as locator
$$('[ng-repeat="server in model.selectedServers | orderBy:\'hostname\'"]').filter(function(foo){
//check for the text in the td with index 1, aka the second one
return foo.$$('td').get(1).getText().then(function(bar){
//return the row which has your value (textproxy)
return bar === "testproxy";
});
//Here you can use the elements in the row with your value
//So you'd want to click the checkbox
}).then(function(values){
values[0].$('[type="checkbox"]').click();
});
这篇关于UI量角器查找和放大器;单击选择框基于文本的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文