在下面的页面中,我必须验证" test_tracker"是否存在。我相信如何做到这一点。任何人都可以帮忙吗?我在gng
之后想到了ng-repeat
,但它给出了零。
element.all(by.repeater("item in
ct.data.pageContentTypes")).count().then(function (count) {
console.log("count value: " + count);
我还能采取什么方法?
代码段:
<div ng-class="detailsChecked ? 'col-sm-8 col-xs-8 col-md-8 col-lg-8' : 'col-sm-12 col-xs-12 col-md-12 col-lg-12'" class="col-sm-12 col-xs-12 col-md-12 col-lg-12">
<!-- ngRepeat: item in ct.data.pageContentTypes -->
<div class="col-sm-3 col-xs-3 col-md-3 col-lg-3 ng-scope" ng-repeat="item in ct.data.pageContentTypes">
<a class="thumbnail" documents-dropzone="" data-category-id="1" ng-click="getContentTypeDetailsByID(item)">
<div ng-class="selectedContentTypeId == '1' ? 'thumbnail-cat thumbnail-cat-public' : 'thumbnail-cat thumbnail-cat-private'" class="thumbnail-cat thumbnail-cat-private">
<span style="word-break:break-all;" class="ng-binding">CORE</span>
</div>
</a>
</div>
<!-- end ngRepeat: item in ct.data.pageContentTypes -->
<div class="col-sm-3 col-xs-3 col-md-3 col-lg-3 ng-scope" ng-repeat="item in ct.data.pageContentTypes">
<a class="thumbnail" documents-dropzone="" data-category-id="72" ng-click="getContentTypeDetailsByID(item)">
<div ng-class="selectedContentTypeId == '72' ? 'thumbnail-cat thumbnail-cat-public' : 'thumbnail-cat thumbnail-cat-private'" class="thumbnail-cat thumbnail-cat-private">
<span style="word-break:break-all;" class="ng-binding">march 13 tt</span>
</div>
</a>
</div>
<!-- end ngRepeat: item in ct.data.pageContentTypes -->
<div class="col-sm-3 col-xs-3 col-md-3 col-lg-3 ng-scope" ng-repeat="item in ct.data.pageContentTypes">
<a class="thumbnail" documents-dropzone="" data-category-id="80" ng-click="getContentTypeDetailsByID(item)">
<div ng-class="selectedContentTypeId == '80' ? 'thumbnail-cat thumbnail-cat-public' : 'thumbnail-cat thumbnail-cat-private'" class="thumbnail-cat thumbnail-cat-private">
<span style="word-break:break-all;" class="ng-binding">NTC NZ MO</span>
</div>
</a>
</div>
<!-- end ngRepeat: item in ct.data.pageContentTypes -->
<div class="col-sm-3 col-xs-3 col-md-3 col-lg-3 ng-scope" ng-repeat="item in ct.data.pageContentTypes">
<a class="thumbnail" documents-dropzone="" data-category-id="87" ng-click="getContentTypeDetailsByID(item)">
<div ng-class="selectedContentTypeId == '87' ? 'thumbnail-cat thumbnail-cat-public' : 'thumbnail-cat thumbnail-cat-private'" class="thumbnail-cat thumbnail-cat-private">
<span style="word-break:break-all;" class="ng-binding">test_tracker</span>
</div>
</a>
</div>
<!-- end ngRepeat: item in ct.data.pageContentTypes -->
<div class="col-sm-3 col-xs-3 col-md-3 col-lg-3 ng-scope" ng-repeat="item in ct.data.pageContentTypes">
<a class="thumbnail" documents-dropzone="" data-category-id="26" ng-click="getContentTypeDetailsByID(item)">
<div ng-class="selectedContentTypeId == '26' ? 'thumbnail-cat thumbnail-cat-public' : 'thumbnail-cat thumbnail-cat-private'" class="thumbnail-cat thumbnail-cat-private">
<span style="word-break:break-all;" class="ng-binding">Tracker Test 0119</span>
</div>
</a>
</div>
<!-- end ngRepeat: item in ct.data.pageContentTypes -->
</div>
&#13;
答案 0 :(得分:0)
最后,下面的代码正在努力解决它
element.all(by.repeater('role in roles.pageitems')).count().then(function (count)
{
console.log("Total number of entries are : " + count)
element.all(by.repeater('role in roles.pageitems')).map(function(elm) {
return elm.getText();
}).then(function(texts) {
console.log("Entries are " + texts);
expect(texts).toContain("" + a + "");
});
});
答案 1 :(得分:-2)
尝试使用Xpath,
var track = element(by.xpath(// span [text()=&#39; test_tracker&#39;]));
track.isPresent()。然后(函数(){
console.log(&#34;轨道可见&#34;);
})