kasmir
v0.6.5
Published
Amazing multi-browser automation tool
Downloads
12
Maintainers
Readme
Kasmir
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 ✦
See some Examples on GitHub or view Full documentation
Also, check out these interesting topics!
HOWTO run multiple browsers
HOWTO long running automation
HOWTO execute custom functions between steps
Installation
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
Simple example
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: ['https://www.github.com']}]
},
'Close page': {
tasks: [{name: 'close client', handler: 'close'}]
}
}
var Kasmir = require('kasmir');
var runner = new Kasmir({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:
runner.run(['Open page', 'Close page']).then(() => {
console.log('Done running!');
});
You can then fetch the report for actions using any of the report functions, for example:
runner.getReport();
Output
Example output report from the test above:
{
actions: [...]
tasks:
[{
id: 'dj9vp58oup3mvrpq77gb9',
action: 'Open page',
name: 'open github.com',
state: 'success',
startTime: 1488383856803,
endTime: 1488383860119,
runTime: 3315,
error: null,
value: true
},
...
errors: [...]
}
See below for more examples & documentation
Examples
See some examples on GitHub
Documentation
See the full documentation
Questions
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?