GithubHelp home page GithubHelp logo

paw's Introduction

PawJS

catpaw

Paw simulates touches and touch gestures including taps, holds, swipes, pinches, and custom gestures. It comes with a touch recorder that can record your interactions and emit javascript code that you can load right into Paw to play your custom recorded gestures.

This is great for automated testing of these interactions in a repeatable way, especially on mobile.

Install using bower

# install bower if you haven't already
$ npm install -g bower

# install this package
$ bower install [email protected]:Workiva/paw.git

If you are using RequireJS

  • In your requirejs configuration, ensure the following config exists:
requirejs.config({
    paths: {
        'paw': 'bower_components/paw/src/'
    }
});

If you want to use the Paw Gesture Recorder in your project

  • Install paw as an npm dev dependency
  • run the paw-record script
npm install paw --save-dev
./node_modules/.bin/paw-record # starts the recorder

Protip: Add ./node_modules/.bin to your path to be able to run paw-record without specifying the path

Try the demos

cd paw
npm install
bower install
grunt serve

Usage / Examples

Paw is wrapped using the universal module definition pattern so it can used by either AMD or CommonJS module loaders or just included into a page via a script tag. Once you've constructed a new Paw you can start chaining calls to gestures. All calls are sequenced internally so you can write nice fluent style code like this:

var paw = new Paw();

// Taps at 100x100, then waits for 1 second, then swipes diagonally. 
// The swipe takes 1 second
// You can also sequence in any function, in this case we love kool-aid.

paw.tap('100px 100px')
   .wait(1000)
   .swipe('top left', 'bottom right' )
   .then(function() { alert('oh yeah!'); })

// Tap on a matching DOM element
paw.tap('#myBtnId');
// same as
paw.tap(document.getElementById('myBtnId'));
// same as
// Tap on a jQuery selector (FYI Paw does not depend on jQuery)
paw.tap( $('#myBtnId') );

// You can add custom gestures to Paw

var customGestures = {
  downUp: function(done) {
    this
    .touch('50% 20%')
    .wait(40)
    .drag('50% 40%')
    .wait(40)
    .drag('50% 20%')
    .wait(40)
    .release()
    .then(done);
}
var paw = new Paw(customGestures);
paw.downUp(); // runs your custom gesture

Project Structure

  • bower_components libraries distributed by Bower
  • docs project design and API documentation
  • node_modules libraries distributed by NPM
  • out output from build tasks
  • src source files
  • test test files
  • tools supporting tools for code quality, builds, etc.

Development: Process

This project uses wf-grunt for building.

Credit

Credit goes to faketouches which inspired this code.

paw's People

Contributors

charliekump-wf avatar robbecker-wf avatar jayudey-wf avatar trentgrover-wf avatar

Watchers

Tobias Kundig avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.