zhuochun / monkey

πŸ™ˆ Naughty monkeys playing on your pages

Home Page:https://github.com/zhuochun/monkey

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Monkey.js

Naughty monkeys playing on your pages.

Monkey.js is a simple monkey testing library for web pages.

It is inspired by gremlins.js. However, Monkey.js is simpler, supports restricting DOM element for test and replay the actions.

Usage

Create a naughty monkey:

<script src="../src/monkey.js"></script>
<script>
  var monkey = new Monkey().behaviour(new ClickBehaviour().getHandler());

  monkey.play();
  monkey.replay();
</script>

Fastest way to have a monkey on a page, open Developer Tool, copy and paste the following:

function loadJS(src, cb) {
    var doc = document, tag = "script", script = doc.createElement(tag), ref = doc.getElementsByTagName(tag)[0];
    script.async = 1; script.src = src;
    ref.parentNode.insertBefore(script, ref);
    script.onload = cb;
}

loadJS('https://cdn.rawgit.com/zhuochun/monkey/master/src/monkey.js', function() {
  var monkey = new Monkey().behaviour(new ClickBehaviour().getHandler()); monkey.play();
});

To create a custom behaviour:

var monkey = new Monkey();

monkey.behaviour(function(ev) {
  // ev.x      screen position x
  // ev.y      screen position y
  // ev.elem   DOM element under position x,y

  // plot a circle at x, y position
  Monkey.utils.plotPoint(ev.x, ev.y);
});

Examples in demo/demo.html.

License

MIT 2014 @ Zhuochun.

About

πŸ™ˆ Naughty monkeys playing on your pages

https://github.com/zhuochun/monkey


Languages

Language:CoffeeScript 68.4%Language:HTML 31.6%