0

请指导我如何使用量角器浏览不同的分页页面,我关注了这个博客:http ://seleniumhome.blogspot.com/2013/07/how-can-we-automate-pagination-using.html ,不幸的是代码不管用。这是我的应用程序中的代码:

<div class="vertical-align">
<ul class="pagination no-margins">
<li class="arrow unavailable" ng-class="{unavailable: currentPage === 0 || pagedRowsTotal.length == 0}">
<a class="ng-binding" ng-click="loadPage(0)" ng-bind-html="rsPaginatorText.first">First</a>
</li>
<li class="arrow unavailable" ng-class="{unavailable: currentGroup === 1 || pagedRowsTotal.length == 0}">
<li class="arrow unavailable" ng-class="{unavailable: currentPage === 0 || pagedRowsTotal.length == 0}">
<a class="ng-binding" ng-click="loadPage(currentPage - 1)" ng-bind-html="rsPaginatorText.previous">Previous</a>
</li>
<!-- ngRepeat: page in groupArray track by $index -->
<li class="ng-scope current" ng-class="{current: page === (currentPage + 1)}" ng-repeat="page in groupArray track by $index">
<a class="ng-binding" ng-click="loadPage(page-1)">1</a>
</li>
<!-- end ngRepeat: page in groupArray track by $index -->
<li class="ng-scope" ng-class="{current: page === (currentPage + 1)}" ng-repeat="page in groupArray track by $index">
<a class="ng-binding" ng-click="loadPage(page-1)">2</a>
</li>
<!-- end ngRepeat: page in groupArray track by $index -->
<li class="ng-scope" ng-class="{current: page === (currentPage + 1)}" ng-repeat="page in groupArray track by $index">
<a class="ng-binding" ng-click="loadPage(page-1)">3</a>
</li>
<!-- end ngRepeat: page in groupArray track by $index -->
<li class="ng-scope" ng-class="{current: page === (currentPage + 1)}" ng-repeat="page in groupArray track by $index">
<a class="ng-binding" ng-click="loadPage(page-1)">4</a>
</li>
<!-- end ngRepeat: page in groupArray track by $index -->
<li class="ng-scope" ng-class="{current: page === (currentPage + 1)}" ng-repeat="page in groupArray track by $index">
<a class="ng-binding" ng-click="loadPage(page-1)">5</a>
</li>
<!-- end ngRepeat: page in groupArray track by $index -->
<li class="arrow" ng-class="{unavailable: currentPage === pagedRowsTotal.length -1}">
<a class="ng-binding" ng-click="loadPage(currentPage + 1)" ng-bind-html="rsPaginatorText.next">Next</a>
</li>
<li class="arrow" ng-class="{unavailable: currentGroup === groupsTotal}">
<li class="arrow" ng-class="{unavailable: currentPage === pagedRowsTotal.length -1}">
<a class="ng-binding" ng-click="loadPage(pagedRowsTotal.length - 1)" ng-bind-html="rsPaginatorText.last">Last</a>
</li>
</ul>

这是我尝试过的,但收到错误:

this.getPaginationsize = element.all(by.repeater('page in groupArray track by $index'));

summaryPage.getPaginationsize.getSize().then(function (pagination) {
            if (pagination > 0) {

                for (var i = 0; i < pagination; i++) {
                    summaryPage.getPaginationsize.get(i).click();
                }
            } else {
                console.log('Pagination not exists');
            }
        });

Failed: Cannot convert object to primitive value
4

1 回答 1

1

summaryPage.getPaginationsize.getSize()方法将返回一个具有 web 元素高度和宽度的对象。相反,您需要使用summaryPage.getPaginationsize.count()来获取 pageSize 的总数。

参考:

getSize()http count() : //www.protractortest.org/#/api? view=webdriver.WebElement.prototype.getSize :http://www.protractortest.org/#/api?view=ElementArrayFinder.prototype.count

于 2017-09-13T05:03:02.770 回答