{"id":19845364,"url":"https://github.com/qavajs/po-cypress","last_synced_at":"2025-10-05T09:48:47.088Z","repository":{"id":243639841,"uuid":"655676464","full_name":"qavajs/po-cypress","owner":"qavajs","description":"library for plain-english access to page object for cypress binding","archived":false,"fork":false,"pushed_at":"2024-06-10T09:34:30.000Z","size":254,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-10T11:24:29.880Z","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-06-19T11:22:54.000Z","updated_at":"2024-06-10T11:24:37.268Z","dependencies_parsed_at":"2024-06-10T11:35:35.159Z","dependency_job_id":null,"html_url":"https://github.com/qavajs/po-cypress","commit_stats":null,"previous_names":["qavajs/po-cypress"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fpo-cypress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fpo-cypress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fpo-cypress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fpo-cypress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qavajs","download_url":"https://codeload.github.com/qavajs/po-cypress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224278484,"owners_count":17285080,"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":["qa","test-automation","testing"],"created_at":"2024-11-12T13:07:24.676Z","updated_at":"2025-10-05T09:48:42.044Z","avatar_url":"https://github.com/qavajs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## @qavajs/po-cypress\n\nThis library provides the ability to create hierarchical page objects and access elements using plain-english selectors.\nWorks on top of Cypress.\n\n`npm install @qavajs/po-cypress`\n## Usage\n\nLib provides getElement method that resolves plain-english selector and return playwright locator.\n```javascript\nconst { po } = require('@qavajs/po-cypress');\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-cypress');\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-cypress');\nconst pos = require('./app.js');\nBefore(async function() {\n    po.init(page, { timeout: 10000 });  // page is an instance of playwright page\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-cypress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqavajs%2Fpo-cypress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqavajs%2Fpo-cypress/lists"}