As you know, CasperJS/PhantomJS is perfect for automation test in client-side. And nowaday, you usually develop lazyload function that means when you pull the scroll of window or element (div html tag) to the bottom of page, the page will automatically load more data and bind it to the view (table or grid). Along with it, we need write unit test function to cover fully user experiences.
With PhantomJS/CasperJS, It is quite easy, just take a look to the source code below. You just need 2 main functions of CasperJS is scrollToBottom and waitFor to implement it.
1 2 3 4 5 6 7 8 9 10 11 12 |
firstRowNumbers = 30; casper.then(function (){ casper.waitFor(function (){ this.scrollToBottom(); // Count row number in grid here: e.g: totalRowNumbers = grid.countRows(); if (firstRowNumbers < totalRowNumbers){ test.assert(true); return true; } }); }) |