Monday, September 25, 2017

Automation Testing With Slimerjs and CasperJS


Today i will talk about automation testing using CasperJS and SlimerJS to automate Smoke testing or simple test scenarios for a website.

So this post is intended for readers who are well versed on testing methods and tools. If you cannot understand any of the portion just google the term and research on it.

To start about Casperjs it can be downloaded from

http://casperjs.org/

or people who want to use npm they can just do the following -


  • mkdir caspertestexample
  • cd caspertestexample
  • npm init
  • npm install --save caperjs

Using the above commands creates a directory called caspertestexample, initializes the folder as a node folder and then installs the casperjs files on the local directory.

So this was about casperjs now the next step is to install slimerjs which is a support for casperjs to perform UI automation. Casperjs basically is an open source tool to navigate through websites and perform user tasks, we need a browser to do the work thus slimerjs comes into the scene. We can use phantomjs instead of slimer but it won't show ui to user to understand that the tests are being performed.

Next we need to do install slimerjs same as caperjs -

  • npm install --save slimerjs
After installing we need to create a tests folder under caspertestexample folder.
This would be like the main folder which will have all the tests.

Basically we have to write test in a javascript file and then run it using casperjs command through command line.

A sample syntax will be like - 



Now we save this file as sample.js and try to run from command prompt.

  • casperjs --verbose --engine=slimerjs test tests

What it will do it will start testing all the files that are under the tests folder one after another using slimerjs as a browser.

P.S. Slimerjs uses the mozilla gecko driver to run the tests.


No comments: