Skip to content

Instantly share code, notes, and snippets.

@werelax
Last active August 29, 2015 13:59
Show Gist options
  • Save werelax/10718339 to your computer and use it in GitHub Desktop.
Save werelax/10718339 to your computer and use it in GitHub Desktop.
little script to automate user interactions in development
/* jshint ignore:start */
var bot = (function() {
var timeline = 0;
return function bot (timeout) {
function evter(evt, sel) {
var args = [].slice.call(arguments, 2);
return function() { var $n; ($n = $(sel))[evt].apply($n, args); };
}
return function(evt, node) {
setTimeout(evter.apply({}, arguments), timeline += timeout);
return bot;
};
}
})();
// Usage example:
// (ms-from-last-action)("jquery-method", "selector", [param1], [param2], ...)
bot
(300)("click", "#RESTAURANT_BOOKINGS")
(300)("click", ".js-table-body .cell:eq(10)")
(300)("val", ".item-room input", "5000")
(0)("trigger", ".item-room input", "keyup")
(3000)("click", ".js-close");
/* jshint ignore:end */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment