{"id":13447600,"url":"https://github.com/HuddleEng/puppeteer-extensions","last_synced_at":"2025-03-22T01:31:08.948Z","repository":{"id":29923421,"uuid":"123148492","full_name":"HuddleEng/puppeteer-extensions","owner":"HuddleEng","description":"Convenience functions for the Puppeteer","archived":false,"fork":false,"pushed_at":"2023-03-04T02:35:30.000Z","size":1520,"stargazers_count":25,"open_issues_count":8,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T16:40:05.884Z","etag":null,"topics":["puppeteer","testing","ui","utilities"],"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/HuddleEng.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-27T15:26:27.000Z","updated_at":"2024-08-04T09:38:57.000Z","dependencies_parsed_at":"2024-06-19T14:34:11.130Z","dependency_job_id":"479a8db5-de1a-464f-9fa1-2abd804f0065","html_url":"https://github.com/HuddleEng/puppeteer-extensions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuddleEng%2Fpuppeteer-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuddleEng%2Fpuppeteer-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuddleEng%2Fpuppeteer-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuddleEng%2Fpuppeteer-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HuddleEng","download_url":"https://codeload.github.com/HuddleEng/puppeteer-extensions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244893418,"owners_count":20527585,"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":["puppeteer","testing","ui","utilities"],"created_at":"2024-07-31T05:01:22.098Z","updated_at":"2025-03-22T01:31:08.638Z","avatar_url":"https://github.com/HuddleEng.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# puppeteer-extensions\n[![Build Status](https://travis-ci.org/HuddleEng/puppeteer-extensions.svg?branch=master)](https://travis-ci.org/HuddleEng/puppeteer-extensions)\n\nThis library exposes a number of convenience functions to extend Puppeteer's API, in order to make writing tests easier.\nThe idea is that many of these functions (or similar ones) will eventually make their way into Puppeteer's own API, but \nthis allows us to experiment with new ways of improving UI testing.\n\n## Usage\n- `page` Puppeteer page instance\n- `timeout` [Optional] Timeout for waits in milliseconds (default: 5000 ms)\n\n```javascript\nconst extensions = require('puppeteer-extensions')(page);\n```\n\n```javascript\n(async() {\n    const listItem = '.todo-list li';\n    ...\n    await extensions.waitForNthSelectorAttributeValue(listItem, 1, 'class', 'completed');\n})();\n\n```\n\n\n## API\nThe API is split into categories to better organise the extension functions. This currently includes:\n\n- [Waits](#waits)\n- [Retrieval](#retrieval)\n- [Miscellaneous](#miscellaneous)\n\n\n**resetRequests()**\n\nResets the requests cache used by the `waits` API. This should be called when you are going to navigate to another page,\nin order to track the new requests correctly. \n\n## Waits\n**waitForResource(resource, timeout=defaultTimeout)**\n- `resource` \\\u003cstring\u003e The URL of the resource (or a substring of it)\n- `timeout` \\\u003cnumber\u003e Timeout for the check\n\nWait for a resource request to be responded to\n\n\n**waitForLoadedWebFontCountToBe(count, timeout=defaultTimeout)**\n- `count` \\\u003cnumber\u003e The number of web fonts to expect\n- `timeout` \\\u003cnumber\u003e Timeout for the check\n\nWait for a specific number of web fonts to be loaded and ready on the page\n\n\n**waitForFunction(fn, options, ...args)**\n- `fn` \\\u003cfunction\u003e The function to execute on the page\n- `options` \\\u003cobject\u003e Optional waiting parameters\n- `args` \\\u003c...args\u003e Arguments to be passed into the function\n\nWait for function to execute on the page (see [waitForFunction](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitforfunctionpagefunction-options-args))\n\n\n**waitUntilExistsAndVisible(selector)**\n- `selector` \\\u003cstring\u003e The selector for the element on the page\n\nWait until an element exists on the page and is visible (i.e. not transparent) (see [waitForSelector](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitforselectorselector-options))\n\n\n**waitWhileExistsAndVisible(selector)**\n- `selector` \\\u003cstring\u003e The selector for the element on the page\n\nWait while an element still exists on the page and is visible (i.e. not transparent) (see [waitForSelector](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitforselectorselector-options))\n\n\n**waitUntilSelectorHasVisibleContent(selector)**\n- `selector` \\\u003cstring\u003e The selector for the element on the page\n\nWait until the selector has visible content (i.e. the element takes up some width and height on the page) (i.e. not transparent)\n\n\n**waitWhileSelectorHasVisibleContent(selector)**\n- `selector` \\\u003cstring\u003e The selector for the element on the page\n\nWait while the selector has visible content (i.e. the element takes up some width and height on the page) (i.e. not transparent)\n\n\n**waitForNthSelectorAttribute(selector, nth, attributeName)**\n- `selector` \\\u003cstring\u003e The selector for the element on the page\n- `nth` \\\u003cnumber\u003e The nth element found by the selector\n- `attributeName` \\\u003cstring\u003e The attribute name to look for\n\nWait for the nth element found from the selector has a particular attribute\n\n\n**waitForSelectorAttribute(selector, attributeName)**\n- `selector` \\\u003cstring\u003e The selector for the element on the page\n- `attributeName` \\\u003cstring\u003e The attribute name to look for\n\nWait for the element found from the selector has a particular attribute\n\n\n**waitForNthSelectorAttributeValue(selector, nth, attributeName, attributeValue)**\n- `selector` \\\u003cstring\u003e The selector for the element on the page\n- `nth` \\\u003cnumber\u003e The nth element found by the selector\n- `attributeName` \\\u003cstring\u003e The attribute name to look for\n- `attributeValue` \\\u003cstring\u003e The attribute value to match the attributeName\n\nWait for the nth element found from the selector has a particular attribute value pair\n\n\n**waitForSelectorAttributeValue(selector, attributeName, attributeValue)**\n- `selector` \\\u003cstring\u003e The selector for the element on the page\n- `attributeName` \\\u003cstring\u003e The attribute name to look for\n- `attributeValue` \\\u003cstring\u003e The attribute value to match the attributeName\n\nWait for the element found from the selector has a particular attribute value pair\n\n\n**waitForElementCount(selector, expectedCount)**\n- `selector` \\\u003cstring\u003e The selector for the element on the page\n- `expectedCount` \\\u003cnumber\u003e The number of elements to expect\n\nWait for the element count to be a particular value\n\n\n**waitForDocumentTitle(title)**\n- `title` \\\u003cstring\u003e The expected title of the document\n\nWait for the document title to be a particular string\n\n\n**waitForUrl(regex)**\n- `regex` \\\u003cRegExp\u003e The regular expression to match the URL on\n\nWait for the current window location to match a particular regular expression\n\n\n**waitFor(milliseconds)**\n- `milliseconds` \\\u003cnumber\u003e The number of milliseconds to wait for\n\nWait for a given number of milliseconds\n\n\n## Retrieval\n\n**getValue(selector)**\n- `selector` \\\u003cstring\u003e The selector for the element to get the value for\n- **returns** \\\u003cstring\u003e The value property value for the element\n\nGet the value property value for a particular element\n\n\n**getText(selector)**\n- `selector` \\\u003cstring\u003e The selector for the element to get the text for\n- **returns** \\\u003cstring\u003e The text property value for the element\n\nGet the text property value for a particular element\n\n\n**getPropertyValue(selector, property)**\n- `selector` \\\u003cstring\u003e The selector for the element to get the property value for\n- `property` \\\u003cstring\u003e The property to look for\n- **returns** \\\u003cstring\u003e The property value for the element\n\nGet the value of a particular property for a particular element\n\n\n**isElementFocused(selector)**\n- `selector` \\\u003cstring\u003e The selector of the element to check for focus state\n- **returns** \\\u003cboolean\u003e Whether the element is focused or not\n\nCheck if element is focused\n\n## Miscellaneous\n\n**turnOffAnimations()**\n\nTurn off CSS animations on the page to help avoid flaky visual comparisons\n\n\n**fastForwardTime(milliseconds)**\n- `milliseconds` \\\u003cnumber\u003e The number of milliseconds to fast forward\n\nFast forward the current time by a given number of milliseconds\n\n\n**evaluate(fn, ...args)**\n- `fn` \\\u003cfunction\u003e The function to execute on the page\n- `args` \\\u003c...args\u003e Arguments to be passed into the function\n\nRuns a function on the page","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHuddleEng%2Fpuppeteer-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHuddleEng%2Fpuppeteer-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHuddleEng%2Fpuppeteer-extensions/lists"}