如何测试滚动时在表中加载更多行?

时间:2019-04-08 20:36:12

标签: protractor

我正在角度应用上使用量角器测试无限滚动。该表最初有50行,这些行在加载网址时显示。滚动后,将显示接下来的50行。同样显示800-900行。这意味着我必须至少滚动16到18次。接下来的50行需要大约3秒的加载时间。如何使用量角器对此进行测试?

我正在使用滚动到View来加载行。

var tableRows = element.all(by.css('tbody tr'));
        let lastCount = 0
        let count = -1
        const go = () => tableRows.count().then(function (rowCount) {
            lastCount = count
            count = rowCount
            console.log("Count:" +count)
            console.log("lastCount: "+lastCount)
            browser.executeScript(e => e.scrollIntoView(), tableRows.last());
            browser.sleep(3000)
            if (lastCount !== count) {
                console.log("going again")
                go()
            }
            else{
                console.log("In Else")

callback();


这是我的HTML


<tbody infinite-scroll="$ctrl.loadInventories()" infinite-scroll-container="'.table-wrapper'" md-body="" class="md-body ng-isolate-scope">
<!-- ngRepeat: data in $ctrl.inventories | orderBy: myOrder -->
<tr class="" ng-repeat="data in $ctrl.inventories | orderBy: myOrder" style="">

<!-- ngRepeat: data in $ctrl.inventories | orderBy: myOrder -->
<tr class="" ng-repeat="data in $ctrl.inventories | orderBy: myOrder" style="">

<!-- ngRepeat: data in $ctrl.inventories | orderBy: myOrder -->
<tr class="" ng-repeat="data in $ctrl.inventories | orderBy: myOrder" style="">

<!-- ngRepeat: data in $ctrl.inventories | orderBy: myOrder -->
<tr class="" ng-repeat="data in $ctrl.inventories | orderBy: myOrder" style="">

1 个答案:

答案 0 :(得分:1)

您可以尝试进行tr计数。如果初始tr计数不等于最终tr计数,请继续循环,如果计数匹配,则可以确认所有行已加载,不再剩余。希望对您有帮助