Kasmir is an amazingly powerful browser automation tool and end-to-end test runner. It gives you complete control over the outcome of your browser based tests, producing a JSON report that includes extended information about each step. You can use the output to handle very flexible failure conditions in your tests and perform complex automation tasks.
It wraps NightwatchJS so every browser command supported by it is also supported by Kasmir. It allows you to launch multiple clients with a single instance, run custom functions between steps and even specify when to continue running if some steps fail.
✦ Easy configuration ✦ Multiple browsers ✦ Reusable steps ✦ Flexible conditions ✦ Robust ✦
Also, check out these interesting topics!
You will need a selenium server to run browser actions. Kasmir can download and launch one for you during initialization, so make sure you have Java installed on your system to run the server.
To install Kasmir itself simply do:
npm install kasmir
To automate browser actions, you will need to define your actions and pass them to Kasmir during initialization. Actions consist of
tasks which contain your browser commands. For example:
var myactions ='Open page':tasks: name: 'open github.com' handler: 'open' args: '''Close page':tasks: name: 'close client' handler: 'close'var Kasmir = ;var runner = actions: myactions;
Once your actions are defined you can simply call the
run() method for whatever actions you wish to perform. Here we open github.com and then close the browser:
You can then fetch the report for actions using any of the report functions, for example:
Example output report from the test above:
actions: ...tasks:id: 'dj9vp58oup3mvrpq77gb9'action: 'Open page'name: 'open github.com'state: 'success'startTime: 1488383856803endTime: 1488383860119runTime: 3315error: nullvalue: true...errors: ...
See below for more examples & documentation
See some examples on GitHub
See the full documentation
Why would I want to use it?
Browser automation has never been this easy! You can perform very complex tasks with simple configuration. You can run actions in multiple browsers that can depend on each other. You can perform long running automation tasks with arbitrary callbacks between actions. Pretty cool!
Why would I want to use it for testing?
Kasmir tests are very robust. One goal of this project is to combat test flakiness and allow you to skip steps and continue running the test on certain conditions. Kasmir also allows you to define very flexible action patterns that are reusable and repeatable.
But Nightwatch already makes writing tests very easy?
Yes indeed, but you still need to write your tests in code and implement your own structure for complex cases. Let's say you want to continue running actions even if some steps fail. Or you might want to fail a test in case some steps take too long. With Kasmir you only have to provide a configuration file, run the test and do whatever you want with the output.
What are some example cases where Kasmir is useful?
✦ Want perform complex browser automation tasks with simple configuration?
✦ Want to easily run actions in multiple browsers in parallel?
✦ Want to run pre-defined action patterns multiple times without repeating youself?
✦ Want to run custom sync/async functions between actions?
✦ Want to fail an e2e test if rendering a page or element takes too long?