How can I get protractor to scroll down on a table? My table does infinite scrolling - it loads 20 records, and when the second-to-last-row is displayed, it fetches the next 20 records. Not all records are in view...some are below yet to be scrolled into, and some are above when the user has scrolled past it. I was thinking the test is
it('should fetch next set of records on scroll') {
element.all(by.id('users')).map(function (elm) {
return elm;
}).then(function (users) {
expect(users.length).toBe(20);
});
// Scroll the table to the bottom to trigger fetching more records
element.all(by.id('users')).map(function (elm) {
return elm;
}).then(function (users) {
expect(users.length).toBe(40);
});
};
Is this the right way of doing this?
HTML table code:
<div ng-if="users && users.length > 0" class="table-scroll" ng-infinite-scroll="loadMoreUsers()">
<table id="users-table" class="table table-hover text-overflow-ellipsis">
<thead>
<td class="col1"></td>
<td id="users-table-name-col" class="col2">User</td>
<td id="users-table-date-col" class="col3">Birthday</td>
</thead>
<tbody ng-repeat="group in users">
<tr ng-repeat="user in group.users" ng-click="userClicked(user);">
<td class="col1">
<img class="col-xs-1 profile-picture" style="padding:0" ng-src="{{user.profile_picture}}"></td>
<td class="col2">
<div id="user-name"> {{ user.last_name }}, {{ user.first_name }} </div>
</td>
<td class="col3">
<div id="user-date"> {{user.date}} </div>
</td>
</tr>
</tbody>
</table>
</div>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…