#casperjs

CasperJS test lazyload

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.

CasperJS test lazyload

Life is what we make it, always has been, always will be

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.

 

Install NodeJS, PhantomJS, CasperJS in Ubuntu 14.04

In my previous project, I used PhantomJS/CasperJS for automation test. It is really amazing for all front-end guys who need write unit test for verify user experiences (e.g: submit form, change link …). The below is steps to install PhantomJS and CasperJS in Ubuntu 14.04.

Install NodeJS, PhantomJS, CasperJS in Ubuntu 14.04

Install NodeJS, PhantomJS, CasperJS in Ubuntu 14.04

Get nodeJS from personal Repository to get the latest version.

Install NPM, NodeJS:

Now, check with command:

You can install CasperJS via NPM command:

Install PhantomJS  (Download source, extract files, create soft-link to executable directory):

Check your installation with command: