{"id":16175897,"url":"https://github.com/elaichenkov/expected-condition-playwright","last_synced_at":"2025-10-05T18:41:19.777Z","repository":{"id":105032944,"uuid":"285923037","full_name":"elaichenkov/expected-condition-playwright","owner":"elaichenkov","description":"expected-condition-playwright is a Node.js library for Playwright and Puppeteer that supplies a set of common conditions that provides functionalities to wait for certain conditions till a defined task is complete","archived":false,"fork":false,"pushed_at":"2022-03-25T08:55:14.000Z","size":20,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T13:31:22.173Z","etag":null,"topics":["automation","playwright","puppeteer","test-tools","testing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/elaichenkov.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":"2020-08-07T21:21:43.000Z","updated_at":"2024-07-27T14:57:16.000Z","dependencies_parsed_at":"2023-06-01T18:00:51.270Z","dependency_job_id":null,"html_url":"https://github.com/elaichenkov/expected-condition-playwright","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"ce1532f524c62687470904f13943e729e723ffb7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elaichenkov%2Fexpected-condition-playwright","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elaichenkov%2Fexpected-condition-playwright/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elaichenkov%2Fexpected-condition-playwright/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elaichenkov%2Fexpected-condition-playwright/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elaichenkov","download_url":"https://codeload.github.com/elaichenkov/expected-condition-playwright/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955696,"owners_count":20374374,"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","playwright","puppeteer","test-tools","testing"],"created_at":"2024-10-10T04:46:41.680Z","updated_at":"2025-10-05T18:41:19.693Z","avatar_url":"https://github.com/elaichenkov.png","language":"TypeScript","readme":"[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://vshymanskyy.github.io/StandWithUkraine)\n\n# Expected Condition\n\n\u003e expected-condition-playwright is a Node.js library for [Playwright](https://github.com/microsoft/playwright) and [Puppeteer](https://github.com/puppeteer/puppeteer) that supplies a set of common conditions that provides functionalities to wait for certain conditions till a defined task is complete.\n\n## Table of Contents\n\n- [Expected Condition](#expected-condition)\n  - [Table of Contents](#table-of-contents)\n  - [Getting Started](#getting-started)\n    - [Installation](#installation)\n    - [Import and usage](#import-and-usage)\n  - [Types of Expected Conditions](#types-of-expected-conditions)\n    - [attributeValueToBe](#attributevaluetobe)\n    - [attributeValueContains](#attributevaluecontains)\n    - [attributeToBeNotEmpty](#attributetobenotempty)\n    - [numberOfElementsToBe](#numberofelementstobe)\n    - [invisibilityOf](#invisibilityof)\n    - [textToBePresentInElement](#texttobepresentinelement)\n    - [textToBePresentInElementValue](#texttobepresentinelementvalue)\n    - [elementToBeClickable](#elementtobeclickable)\n    - [elementToBeSelected](#elementtobeselected)\n    - [titleEquals](#titleequals)\n    - [titleContains](#titlecontains)\n    - [urlEquals](#urlequals)\n    - [urlContains](#urlcontains)\n  - [License](#license)\n\n## Getting Started\n\n### Installation\n\nTo use expected-condition-playwright in your project, run:\n\n```bash\nnpm i -D expected-condition-playwright\n```\n\n### Import and usage\n\n**_TypeScript_**\n\n```ts\n// Import ExpectedCondition class as EC shortcut\nimport { ExpectedCondition as EC } from 'expected-condition-playwright';\n\n// Simple selector\nconst submitButton = 'button';\n\n// Use page's waitForFunction method to provide the elementToBeClickable method to instruct a command to wait until the element is clickable by the selector\nawait page.waitForFunction(EC.elementToBeClickable(submitButton), submitButton, { timeout: 5000 });\n```\n\n**_JavaScript_**\n\n```ts\n// Require ExpectedCondition class as EC shortcut\nconst { ExpectedCondition: EC } = require('expected-condition-playwright');\n\n// Simple selector\nconst submitButton = 'button';\n\n// Use page's waitForFunction method to provide the elementToBeClickable method to instruct a command to wait until the element is clickable by the selector\nawait page.waitForFunction(EC.elementToBeClickable(submitButton), submitButton, { timeout: 5000 });\n```\n\n## Types of Expected Conditions\n\n### attributeValueToBe\n\nAn expectation for checking element with given selector has attribute with a specific value\n\n**_Usage_**\n\n```ts\nconst inputSelector = 'input[type=q]';\nconst expectedAttribute = 'type';\nconst expectedValue = 'q';\n\nawait page.waitForFunction(\n  EC.attributeValueToBe([inputSelector, expectedAttribute, expectedValue]),\n  [inputSelector, expectedAttribute, expectedValue],\n  { timeout: 5000 },\n);\n```\n\n### attributeValueContains\n\nAn expectation for checking element with given selector has attribute which contains a specific value\n\n**_Usage_**\n\n```ts\nconst inputSelector = 'input[type=que]';\nconst expectedAttribute = 'type';\nconst expectedValue = 'q';\n\nawait page.waitForFunction(\n  EC.attributeValueContains([inputSelector, expectedAttribute, expectedValue]),\n  [inputSelector, expectedAttribute, expectedValue],\n  { timeout: 5000 },\n);\n```\n\n### attributeToBeNotEmpty\n\nAn expectation for checking element with given selector any non empty value for given attribute\n\n**_Usage_**\n\n```ts\nconst inputSelector = 'input[type=que]';\nconst expectedAttribute = 'type';\n\nawait page.waitForFunction(\n  EC.attributeValueContains([inputSelector, expectedAttribute]),\n  [inputSelector, expectedAttribute],\n  { timeout: 5000 },\n);\n```\n\n### numberOfElementsToBe\n\nAn expectation for checking number of elements with given selector\n\n**_Usage_**\n\n```ts\nconst links = 'a';\nconst expectedNumber = '12';\n\nawait page.waitForFunction(EC.numberOfElementsToBe([links, expectedNumber]), [links, expectedNumber], {\n  timeout: 5000,\n});\n```\n\n### invisibilityOf\n\nAn expectation for checking the element to be invisible\n\n**_Usage_**\n\n```ts\nconst link = 'a';\n\nawait page.waitForFunction(EC.invisibilityOf(link), links, { timeout: 5000 });\n```\n\n### textToBePresentInElement\n\nAn expectation for checking if the given text is present in the specified element.\n\n**_Usage_**\n\n```ts\nconst logInButton = 'button';\nconst expectedText = 'Log in';\n\nawait page.waitForFunction(EC.textToBePresentInElement([logInButton, expectedText]), [logInButton, expectedText], {\n  timeout: 5000,\n});\n```\n\n### textToBePresentInElementValue\n\nAn expectation for checking if the given text is present in the specified elements value attribute.\n\n**_Usage_**\n\n```ts\nconst userField = 'input';\nconst expectedValue = 'John';\n\nawait page.waitForFunction(EC.textToBePresentInElementValue([userField, expectedValue]), [userField, expectedValue], {\n  timeout: 5000,\n});\n```\n\n### elementToBeClickable\n\nAn expectation for checking the element is visible and enabled such that you can click it.\n\n**_Usage_**\n\n```ts\nconst nextButton = 'button';\n\nawait page.waitForFunction(EC.elementToBeClickable(nextButton), nextButton, { timeout: 5000 });\n```\n\n### elementToBeSelected\n\nAn expectation for checking the element is visible and enabled such that you can click it.\n\n**_Usage_**\n\n```ts\nconst checkbox = 'input';\n\nawait page.waitForFunction(EC.elementToBeSelected(checkbox), checkbox, { timeout: 5000 });\n```\n\n### titleEquals\n\nAn expectation for checking the title of a page.\n\n**_Usage_**\n\n```ts\nconst expectedTitle = 'Playwright';\n\nawait page.waitForFunction(EC.titleEquals(expectedTitle), expectedTitle, { timeout: 5000 });\n```\n\n### titleContains\n\nAn expectation for checking that the title contains a case-sensitive substring\n\n**_Usage_**\n\n```ts\nconst expectedTitle = 'Play';\n\nawait page.waitForFunction(EC.titleContains(expectedTitle), expectedTitle, { timeout: 5000 });\n```\n\n### urlEquals\n\nAn expectation for the URL of the current page to be a specific url.\n\n**_Usage_**\n\n```ts\nconst expectedUrl = 'http://github.com/';\n\nawait page.waitForFunction(EC.urlEquals(expectedUrl), expectedUrl, { timeout: 5000 });\n```\n\n### urlContains\n\nAn expectation for the URL of the current page to contain specific text.\n\n**_Usage_**\n\n```ts\nconst expectedUrl = '.com';\n\nawait page.waitForFunction(EC.urlContains(expectedUrl), expectedUrl, { timeout: 5000 });\n```\n\n## License\n\nexpected-condition-playwright is [MIT licensed](./LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felaichenkov%2Fexpected-condition-playwright","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felaichenkov%2Fexpected-condition-playwright","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felaichenkov%2Fexpected-condition-playwright/lists"}