{"id":29238919,"url":"https://github.com/evegreen/useractions","last_synced_at":"2025-12-12T04:47:33.870Z","repository":{"id":57364242,"uuid":"65371169","full_name":"evegreen/useractions","owner":"evegreen","description":"[DEPRECATED] Library, that helps simulate user actions for write fast functional tests","archived":false,"fork":false,"pushed_at":"2018-05-24T14:47:23.000Z","size":706,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-09T21:28:01.854Z","etag":null,"topics":["e2e","e2e-tests","simulation","testing","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evegreen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-10T09:52:17.000Z","updated_at":"2021-08-16T10:36:31.000Z","dependencies_parsed_at":"2022-09-12T15:13:22.807Z","dependency_job_id":null,"html_url":"https://github.com/evegreen/useractions","commit_stats":null,"previous_names":["evegreen/smoketest"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/evegreen/useractions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evegreen%2Fuseractions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evegreen%2Fuseractions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evegreen%2Fuseractions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evegreen%2Fuseractions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evegreen","download_url":"https://codeload.github.com/evegreen/useractions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evegreen%2Fuseractions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263221883,"owners_count":23433005,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["e2e","e2e-tests","simulation","testing","testing-tools"],"created_at":"2025-07-03T19:01:18.150Z","updated_at":"2025-12-12T04:47:33.841Z","avatar_url":"https://github.com/evegreen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **UserActions**\n\nLibrary, that helps simulate user actions for write fast functional tests fro browsers\n\n## Getting started\n\n### Npm\n\n    npm install useractions --save-dev\n\n---\n\n# Table of contents\n- [Add tests to webpage](#add-tests-to-webpage)\n- [Run tests](#run-tests)\n- [Action methods](#action-methods)\n- [Configure timeouts](#configure-timeouts)\n- [Promisified methods](#promisified-methods)\n- [Already found element](#already-found-element)\n- [Todo section](#todo)\n- [Other](#other)\n\n---\n\n## Add tests to webpage\n\nFor add tests to your webpage, just add it right in simple script.\n[Look to the example](https://github.com/evegreen/useractions/blob/master/tests/regression/exampleApp.html)\n\nBut if you want add lib and tests without change your webpage files, you can use userscripts (tampermonkey / greasemonkey extensions)\n\n---\n\n## Run tests\n\n[Look to the example](https://github.com/evegreen/useractions/blob/master/tests/regression/exampleTestScript.js)\n\n---\n\n## Action methods\n\ninteract methods:\n- [click method](#click-method)\n- [event method](#event-method)\n- [changeValue method](#changevalue-method)\n- [focusOn method](#focuson-method)\n- [blur method](#blur-method)\n- [pickInSelect method](#pickinselect-method)\n- [directClick method](#directclick-method)\n\nget methods:\n- [getText method](#gettext-method)\n- [getValue method](#getvalue-method)\n\ncore methods:\n- [findElement method](#findelement-method)\n- [waitState method](#waitstate-method)\n\n\n\n## Methods API\n\n### click method\n```js\nvar click = userActions.click;\nclick('button#submit', optionalCallback);\n```\n\n\n### event method\n```js\nvar event = userActions.event;\nevent({\n  type: 'click',\n  target: 'button#submit'\n}, optionalCallback);\n```\n\n\n\n### changeValue method\n```js\nvar changeValue = userActions.changeValue;\nchangeValue('input#login', 'John Doe', optionalCallback);\n```\n\n\n### focusOn method\n```js\nvar focusOn = userActions.focusOn;\nfocusOn('input#password', optionalCallback);\n```\n\n\n### blur method\n```js\nvar blur = userActions.blur;\nblur('input#age', optionalCallback);\n```\n\n\n### pickInSelect method\n```js\nvar pickInSelect = userActions.pickInSelect;\n\n// You can pass option value\npickInSelect('select#car', 'mercedez', optionalCallback);\n\n// You can pass option innerHTML\npickInSelect('select#car', 'Mercedez Benz', optionalCallback);\n\n// Or a number of selected value\npickInSelect('select#car', 2, optionalCallback);\n```\n\n### directClick method\n```js\nvar directClick = userActions.directClick;\n\n// this method calls .click() method of element directly (without events)\nclick('#myCheckbox', optionalCallback);\n```\n\n### getText method\n```js\nvar getText = userActions.getText;\ngetText('div#selectedCar', function(err, text) {\n  if (err) throw err;\n\n  // work with text\n});\n```\n\n\n### getValue method\n```js\nvar getValue = userActions.getValue;\ngetValue('input#surname', function(err, value) {\n  if (err) throw err;\n\n  // work with value\n});\n```\n\n\n### findElement method\n```js\nvar findElement = userActions.findElement;\n\n// You can use with default timeout waiting for element presense\nfindElement('div#main', function(err, element) {\n  if (err) throw err;\n\n  // work with element\n});\n\n// Or you can specify need timeout\nfindElement('div#main', 3000, function(err, element) {\n  if (err) throw err;\n\n  // work with element\n});\n```\n\n\n### waitState method\n```js\nvar waitState = userActions.waitState;\n\nwaitState(function() {\n  // this is predicate, it must return boolean value\n  var loadedCarsInList = document.querySelectorAll('ul#cars\u003eli').length;\n  return loadedCarsInList === 12;\n}, function(err) {\n  // this is callback, it will called if predicate returns true, until timeout done\n  if (err) throw err;\n\n  // work with successfully loaded car list\n}, 5000, 1000); // optional timeout and optional refresh time (wait 5 seconds and check predicate every second)\n```\n\n---\n\n## Configure timeouts\n\n### setDefaultRefreshTime method\n```js\n// every waitState method or findElement process will try every second\nuserActions.setDefaultRefreshTime(1000);\n```\n\n\n### setDefaultTimeout method\n```js\n// every waitState method or findElement process will failed after 6 seconds\nuserActions.setDefaultTimeout(6000);\n```\n\n---\n\n## Promisified methods\nAll action methods has promisified version, in example `getText`:\n```js\nvar getText = userActions.promised.getText;\n\ngetText('div#carDescription')\n.then(function(text) { /* work with text =) */ })\n.catch(function(err) { /* handle error =( */ };\n```\n\n---\n\n## Already found element\nAll action methods (promisified too) you can use with already found element.\nIt is comfortable for promise chaining:\n\n```js\nvar promiseActions = userActions.promised;\nvar findElement = promiseActions.findElement;\nvar click = promiseActions.click;\n\nfindElement('#buttonForClick')\n.then(button =\u003e click(button));\n```\n\n---\n\n## TODO\n- [ ] make possible es6 imports, not only IIFE\n- [ ] console-browser integration for test runs\n- [ ] step synchronization for non SPA websites (or crossdomain websites)\n- [ ] headless chrome usage examples\n- [ ] test runs results keeping\n- [ ] test runs results statistics\n- [ ] fix stacktrace after waiting recursive functions\n\n---\n\n## Other\n```js\nuserActions.version();\n```\nReturns version of library and bundled dependencies\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevegreen%2Fuseractions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevegreen%2Fuseractions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevegreen%2Fuseractions/lists"}