{"id":19845374,"url":"https://github.com/qavajs/po-testcafe","last_synced_at":"2025-08-11T07:08:57.243Z","repository":{"id":154222798,"uuid":"631980361","full_name":"qavajs/po-testcafe","owner":"qavajs","description":"library for plain-english access to testcafe page object","archived":false,"fork":false,"pushed_at":"2023-04-24T16:27:44.000Z","size":326,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-05T06:02:14.489Z","etag":null,"topics":["qa","test-automation","testing"],"latest_commit_sha":null,"homepage":null,"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/qavajs.png","metadata":{"files":{"readme":"README.MD","changelog":"CHANGELOG.md","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":"2023-04-24T13:14:18.000Z","updated_at":"2025-01-17T09:55:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"dea34940-51da-4028-b1df-8859bf9f573c","html_url":"https://github.com/qavajs/po-testcafe","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/qavajs/po-testcafe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fpo-testcafe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fpo-testcafe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fpo-testcafe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fpo-testcafe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qavajs","download_url":"https://codeload.github.com/qavajs/po-testcafe/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fpo-testcafe/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269844098,"owners_count":24484132,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["qa","test-automation","testing"],"created_at":"2024-11-12T13:07:32.561Z","updated_at":"2025-08-11T07:08:57.186Z","avatar_url":"https://github.com/qavajs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## @qavajs/po-testcafe\n\nThis library provides the ability to create hierarchical page objects and access elements using plain-english selectors.\nWorks on top of testcafe.\n\n`npm install @qavajs/po-testcafe`\n## Usage\n\nLib provides getElement method that resolves plain-english selector and return testcafe selector.\n```javascript\nconst { po } = require('@qavajs/po-testcafe');\n\nWhen(/^click '(.+)'$/, async function (alias) {\n    const element = await po.getElement(alias);\n    await element.click();\n});\n```\n\n```gherkin\nWhen click '#1 of Multiple Component \u003e Child Item'\n```\n\nLib provides capability to get single element from collection by index (#index of Collection) or inner text (#text in Collection).\n\n## Create page object\n\nLib provides two methods $ and $$ that allow registering elements and collections.\nAn element can be defined in form of webdriverIO selector or as an instance of the component class. \n\nEach not top-level component should have selector element in form of webdriverIO selector.\n```javascript\nconst { $, $$ } = require('@qavajs/po-testcafe');\n\nclass MultipleComponent {\n    selector = '.list-components li';\n    ChildItem = $('div');\n}\n\nclass SingleComponent {\n    selector = '.container';\n    ChildItem = $('.child-item');\n}\n\nclass App {\n    SingleElement = $('.single-element');\n    List = $$('.list li');\n    SingleComponent = $(new SingleComponent());\n    MultipleComponents = $$(new MultipleComponent());\n}\n\nmodule.exports = new App();\n```\n## Register PO\nBefore using po object need to be initiated and hierarchy of elements needs to be registered\nThe best place to do it is cucumber-js Before hook\n\n```javascript\nconst { po } = require('@qavajs/po-testcafe');\nconst pos = require('./app.js');\nBefore(async function() {\n    po.init({ timeout: 10000 });\n    po.register(pos); // pos is page object hierarchy\n});\n```\n\n## Ignore hierarchy\nIn case if child element and parent component doesn't have hierarchy dependency\nit's possible to pass extra parameter _ignoreHierarchy_ parameter to start traverse from root\n\n```javascript\nclass ComponentThatDescribesNotWellDesignedDOMTree {\n    selector = '.container';\n    //ignoreHierarchy will ignore component selector .container and start traverse from root\n    ChildItem = $('.child-item', { ignoreHierarchy: true }); \n}\n```\n\n## Optional selector property\nIf selector property is not provided for Component then parent element will be returned\n\n```javascript\nclass ParentComponent {\n    selector = '.container';\n    ChildComponent = $(new ChildComponent()); \n}\n\nclass ChildComponent {\n    //Element will be searched in parent .container element\n    Element = $('.someElement');\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqavajs%2Fpo-testcafe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqavajs%2Fpo-testcafe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqavajs%2Fpo-testcafe/lists"}