{"id":24686935,"url":"https://github.com/rickypc/form-mutator","last_synced_at":"2025-03-21T21:42:27.041Z","repository":{"id":49073115,"uuid":"245375759","full_name":"rickypc/form-mutator","owner":"rickypc","description":"A utility to fill out web form and mutate field data programmatically","archived":false,"fork":false,"pushed_at":"2021-06-29T13:30:15.000Z","size":32,"stargazers_count":1,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-26T23:16:56.069Z","etag":null,"topics":["automation","fill-out","html-form","input-field","mutator","programmatically","utility","web-form"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/form-mutator","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rickypc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-06T09:13:41.000Z","updated_at":"2023-08-15T09:53:23.000Z","dependencies_parsed_at":"2022-09-08T00:01:02.363Z","dependency_job_id":null,"html_url":"https://github.com/rickypc/form-mutator","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickypc%2Fform-mutator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickypc%2Fform-mutator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickypc%2Fform-mutator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickypc%2Fform-mutator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rickypc","download_url":"https://codeload.github.com/rickypc/form-mutator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244874718,"owners_count":20524581,"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":["automation","fill-out","html-form","input-field","mutator","programmatically","utility","web-form"],"created_at":"2025-01-26T16:17:11.823Z","updated_at":"2025-03-21T21:42:27.018Z","avatar_url":"https://github.com/rickypc.png","language":"JavaScript","readme":"[![Version](https://img.shields.io/npm/v/form-mutator)](https://bit.ly/2VTdnqu)\n[![Downloads](https://img.shields.io/npm/dt/form-mutator)](https://bit.ly/2VTdnqu)\n[![Dependency Status](https://img.shields.io/david/rickypc/form-mutator)](https://bit.ly/3cFYeys)\n[![Dev Dependency Status](https://img.shields.io/david/dev/rickypc/form-mutator)](https://bit.ly/333PdLl)\n[![Code Style](https://img.shields.io/badge/code%20style-Airbnb-red)](https://bit.ly/2JYN1gk)\n[![Build](https://img.shields.io/travis/rickypc/form-mutator)](https://bit.ly/3cG11rq)\n[![Coverage](https://img.shields.io/codecov/c/github/rickypc/form-mutator)](https://bit.ly/39wHtUG)\n[![Vulnerability](https://img.shields.io/snyk/vulnerabilities/github/rickypc/form-mutator)](https://bit.ly/2PWiKRP)\n[![Dependabot](https://api.dependabot.com/badges/status?host=github\u0026repo=rickypc/form-mutator)](https://bit.ly/2KIM5vs)\n[![License](https://img.shields.io/npm/l/form-mutator)](https://mzl.la/2vLmCye)\n\nForm Mutator\n============\n\nA utility to fill out web form and mutate field data programmatically.\n\nBrowser Download\n-\nYou can download [compressed copy](form-mutator.min.js) for browser usage.\n\nNode.js Installation\n-\n\n```bash\n$ npm install --save form-mutator\n```\n\nAPI Reference\n-\nProvide utility to fill out web form and mutate field data programmatically.\n\n**Example** *(Browser usage)*  \n```js\n\u003cscript type=\"text/javascript\" src=\"form-mutator.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  formMutator.fillOut({\n    '[name=\"fullName\"]': 'Your Name',\n    '[name=\"address\"]': '1 Awesome Way',\n    '[name=\"city\"]': 'Lalaland',\n    '[type=\"submit\"]': true,\n  });\n\u003c/script\u003e\n```\n**Example** *(Node.js usage)*  \n```js\nconst formMutator = require('form-mutator');\n\nformMutator.fillOut({\n  '[name=\"fullName\"]': 'Your Name',\n  '[name=\"address\"]': '1 Awesome Way',\n  '[name=\"city\"]': 'Lalaland',\n  '[type=\"submit\"]': true,\n});\n```\n\n* [form-mutator](#module_form-mutator)\n    * [.click](#module_form-mutator.click) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n    * [.deselectByText](#module_form-mutator.deselectByText) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n    * [.fillOut](#module_form-mutator.fillOut) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n    * [.selectByText](#module_form-mutator.selectByText) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n    * [.setValue](#module_form-mutator.setValue) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n    * [.toggleCheckbox](#module_form-mutator.toggleCheckbox) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n    * [.typeValue](#module_form-mutator.typeValue) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n\n\u003ca name=\"module_form-mutator.click\"\u003e\u003c/a\u003e\n\n### form-mutator.click ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nClick on given element.\n\n**Kind**: static property of [\u003ccode\u003eform-mutator\u003c/code\u003e](#module_form-mutator)  \n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - Truthy if click triggered, otherwise falsy.  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| element | \u003ccode\u003eObject\u003c/code\u003e | The element to click. |\n\n**Example**  \n```js\nconst el = document.querySelector('a[href=\"/\"]');\nconst response = formMutator.click(el);\n```\n\u003ca name=\"module_form-mutator.deselectByText\"\u003e\u003c/a\u003e\n\n### form-mutator.deselectByText ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nDeselect given values from dropdown list.\n\n**Kind**: static property of [\u003ccode\u003eform-mutator\u003c/code\u003e](#module_form-mutator)  \n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - Truthy if deselect triggered, otherwise falsy.  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| element | \u003ccode\u003eObject\u003c/code\u003e | The element to deselect from. |\n| values | \u003ccode\u003eArray.\u0026lt;string\u0026gt;\u003c/code\u003e | The values to deselect. |\n\n**Example**  \n```js\nconst el = document.querySelector('[name=\"month\"]');\nconst response = formMutator.deselectByText(el, ['January']);\n```\n\u003ca name=\"module_form-mutator.fillOut\"\u003e\u003c/a\u003e\n\n### form-mutator.fillOut ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nFill out all form field matched given selector =\u003e value key-pair. It will\nskip unknown field type and missing field.\n\n**Kind**: static property of [\u003ccode\u003eform-mutator\u003c/code\u003e](#module_form-mutator)  \n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - Truthy if the values are set, otherwise false.  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| data | \u003ccode\u003eObject\u003c/code\u003e | The selector =\u003e value data map. |\n| data.selector | \u003ccode\u003estring\u003c/code\u003e | The selector to find desired element. |\n| data.value | \u003ccode\u003emixed\u003c/code\u003e | The value to be set. |\n\n**Example**  \n```js\nconst response = formMutator.fillOut({\n  '[name=\"fullName\"]': 'Your Name',\n  '[name=\"address\"]': '1 Awesome Way',\n  '[name=\"city\"]': 'Lalaland',\n  '[type=\"submit\"]': true,\n});\n```\n\u003ca name=\"module_form-mutator.selectByText\"\u003e\u003c/a\u003e\n\n### form-mutator.selectByText ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nSelect given values from dropdown list.\n\n**Kind**: static property of [\u003ccode\u003eform-mutator\u003c/code\u003e](#module_form-mutator)  \n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - Truthy if select triggered, otherwise falsy.  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| element | \u003ccode\u003eObject\u003c/code\u003e | The element to select from. |\n| values | \u003ccode\u003eArray.\u0026lt;string\u0026gt;\u003c/code\u003e | The values to select. |\n\n**Example**  \n```js\nconst el = document.querySelector('[name=\"month\"]');\nconst response = formMutator.selectByText(el, ['January']);\n```\n\u003ca name=\"module_form-mutator.setValue\"\u003e\u003c/a\u003e\n\n### form-mutator.setValue ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nSet given value to input field that match given selector.\n\n**Kind**: static property of [\u003ccode\u003eform-mutator\u003c/code\u003e](#module_form-mutator)  \n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - Truthy if the value is set, or the field is unknown type\nor the field can not be found, otherwise false.  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| selector | \u003ccode\u003estring\u003c/code\u003e | The selector to find desired element. |\n| value | \u003ccode\u003emixed\u003c/code\u003e | The value to be set. |\n\n**Example**  \n```js\nconst response = formMutator.setValue('[type=\"text\"]', 'value');\n```\n\u003ca name=\"module_form-mutator.toggleCheckbox\"\u003e\u003c/a\u003e\n\n### form-mutator.toggleCheckbox ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nToggle the checkbox or radio button field.\n\n**Kind**: static property of [\u003ccode\u003eform-mutator\u003c/code\u003e](#module_form-mutator)  \n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - Truthy if toggle triggered, otherwise falsy.  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| element | \u003ccode\u003eObject\u003c/code\u003e | The element to toggle from. |\n| value | \u003ccode\u003eboolean\u003c/code\u003e | Check if true, otherwise uncheck. |\n\n**Example**  \n```js\nconst el = document.querySelector('[type=\"checkbox\"]');\nconst response1 = formMutator.toggleCheckbox(el, true);  // checked\nconst response2 = formMutator.toggleCheckbox(el, false); // unchecked\n```\n\u003ca name=\"module_form-mutator.typeValue\"\u003e\u003c/a\u003e\n\n### form-mutator.typeValue ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nType given value to password or text field.\n\n**Kind**: static property of [\u003ccode\u003eform-mutator\u003c/code\u003e](#module_form-mutator)  \n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - Truthy if type in triggered, otherwise falsy.  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| element | \u003ccode\u003eObject\u003c/code\u003e | The element to type on. |\n| value | \u003ccode\u003emixed\u003c/code\u003e | The value to be typed in. |\n\n**Example**  \n```js\nconst el = document.querySelector('[type=\"text\"]');\nconst response = formMutator.typeValue(el, 'value');\n```\n\nDevelopment Dependencies\n-\nYou will need to install [Node.js](https://bit.ly/2SMCGXK) as a local\ndevelopment dependency. The `npm` package manager comes bundled with all\nrecent releases of `Node.js`.\n\n`npm install` will attempt to resolve any `npm` module dependencies that have\nbeen declared in the project’s `package.json` file, installing them into the\n`node_modules` folder.\n\n```bash\n$ npm install\n```\n\nRun Linter\n-\nTo make sure we followed code style best practice, run:\n\n```bash\n$ npm run lint\n```\n\nRun Unit Tests\n-\nTo make sure we did not break anything, let's run:\n\n```bash\n$ npm test\n```\n\nContributing\n-\nIf you would like to contribute code to Form Mutator repository you can do so\nthrough GitHub by forking the repository and sending a pull request.\n\nIf you do not agree to [Contribution Agreement](CONTRIBUTING.md), do not\ncontribute any code to Form Mutator repository.\n\nWhen submitting code, please make every effort to follow existing conventions\nand style in order to keep the code as readable as possible. Please also include\nappropriate test cases.\n\nThat's it! Thank you for your contribution!\n\nLicense\n-\nCopyright (c) 2018 - 2020 Richard Huang.\n\nThis utility is free software, licensed under: [Mozilla Public License (MPL-2.0)](https://mzl.la/2vLmCye).\n\nDocumentation and other similar content are provided under [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](https://bit.ly/2SMCRlS).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickypc%2Fform-mutator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frickypc%2Fform-mutator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickypc%2Fform-mutator/lists"}