我在表格中有“案例”列表,我只需要按NAME查找特定案例,然后单击它。
我的HTML看起来像:
<tr ng-repeat-start="case in cases | orderBy:order:order_reverse" class="middle ng-scope odd readonly" ng-class-odd="'odd'" ng-class-even="'even'" ng-class="{readonly: !caseManager.isWritable(case)}">
<td>
<span ax-sharing-circle="SHARED_WITH_PARTNER" class="ng-isolate-scope"><span class="icon sharing-circle sharing-circle-left" title="Sdílený"></span></span>
</td>
<td class="case-table-claim-number fix-v-align">
<a ui-sref="case.general({caseId: case.caseId})" class="ng-binding" href="#/case/0a0b1c2a-94b4-444c-a2b8-c62cbd3532ae/general">20150629-165000-65</a>
</td>
<td class="case-table-claim-number fix-v-align ng-binding"></td>
<td class="case-table-claim-number fix-v-align ng-binding"></td>
<td class="case-table-make fix-v-align ng-binding"></td>
<td class="case-table-make fix-v-align ng-binding"></td>
<td class="case-table-status fix-v-align ng-binding">
29.6.2015
</td>
<td class="case-table-status fix-v-align ng-binding"></td>
<td>
<span class="glyphicon glyphicon-menu-down" ng-class="{
'glyphicon glyphicon-menu-up': hasOverview(case.caseId),
'glyphicon glyphicon-menu-down': !hasOverview(case.caseId),
}" ng-click="toggleOverview(case.caseId)"></span>
</td>
</tr>
在上面的示例中,您可以找到字符串
20150629-165000-65
,它是案例的名称。我尝试写这样的东西:
element(by.cssContainingText('a', global.caseNumber)).click();
应该找到元素并单击它,而不是它引发错误:
使用定位器找不到任何元素:by.cssContainingText(“ a”,“ 20150629-165000-65”)
有人可以告诉我该怎么做吗?
最佳答案
有一个适合该用例的相关by.linkText()
定位符:
var link = element(by.linkText(global.caseNumber));
如果仍然找不到所需的元素,请尝试添加等待:
var EC = protractor.ExpectedConditions;
browser.wait(EC.presenceOf(link), 5000);