UserActions
Library, that helps simulate user actions for write fast functional tests fro browsers
Getting started
Npm
npm install useractions --save-dev
Table of contents
- Add tests to webpage
- Run tests
- Action methods
- Configure timeouts
- Promisified methods
- Already found element
- Todo section
- Other
Add tests to webpage
For add tests to your webpage, just add it right in simple script. Look to the example
But if you want add lib and tests without change your webpage files, you can use userscripts (tampermonkey / greasemonkey extensions)
Run tests
Action methods
interact methods:
- click method
- event method
- changeValue method
- focusOn method
- blur method
- pickInSelect method
- directClick method
get methods:
core methods:
Methods API
click method
var click = userActionsclick;;
event method
var event = userActionsevent;event type: 'click' target: 'button#submit' optionalCallback;
changeValue method
var changeValue = userActionschangeValue;;
focusOn method
var focusOn = userActionsfocusOn;;
blur method
var blur = userActionsblur;;
pickInSelect method
var pickInSelect = userActionspickInSelect; // You can pass option value; // You can pass option innerHTML; // Or a number of selected value;
directClick method
var directClick = userActionsdirectClick; // this method calls .click() method of element directly (without events);
getText method
var getText = userActionsgetText;;
getValue method
var getValue = userActionsgetValue;;
findElement method
var findElement = userActionsfindElement; // You can use with default timeout waiting for element presense; // Or you can specify need timeout;
waitState method
var waitState = userActionswaitState; ; // optional timeout and optional refresh time (wait 5 seconds and check predicate every second)
Configure timeouts
setDefaultRefreshTime method
// every waitState method or findElement process will try every seconduserActions;
setDefaultTimeout method
// every waitState method or findElement process will failed after 6 secondsuserActions;
Promisified methods
All action methods has promisified version, in example getText
:
var getText = userActionspromisedgetText;
Already found element
All action methods (promisified too) you can use with already found element. It is comfortable for promise chaining:
var promiseActions = userActionspromised;var findElement = promiseActionsfindElement;var click = promiseActionsclick; ;
TODO
- make possible es6 imports, not only IIFE
- console-browser integration for test runs
- step synchronization for non SPA websites (or crossdomain websites)
- headless chrome usage examples
- test runs results keeping
- test runs results statistics
- fix stacktrace after waiting recursive functions
Other
userActionsversion;
Returns version of library and bundled dependencies