{"id":18000163,"url":"https://github.com/samueljseay/page_object","last_synced_at":"2025-06-15T16:09:12.128Z","repository":{"id":50695379,"uuid":"61974399","full_name":"samueljseay/page_object","owner":"samueljseay","description":"Page Objects for Hound / Elixir","archived":false,"fork":false,"pushed_at":"2018-06-12T01:00:36.000Z","size":48,"stargazers_count":20,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T04:11:13.664Z","etag":null,"topics":["elixir","elixir-phoenix","hound"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/samueljseay.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}},"created_at":"2016-06-26T04:59:53.000Z","updated_at":"2023-09-01T08:52:51.000Z","dependencies_parsed_at":"2022-09-24T10:10:36.429Z","dependency_job_id":null,"html_url":"https://github.com/samueljseay/page_object","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/samueljseay/page_object","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samueljseay%2Fpage_object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samueljseay%2Fpage_object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samueljseay%2Fpage_object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samueljseay%2Fpage_object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samueljseay","download_url":"https://codeload.github.com/samueljseay/page_object/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samueljseay%2Fpage_object/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260005989,"owners_count":22944867,"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":["elixir","elixir-phoenix","hound"],"created_at":"2024-10-29T23:09:57.280Z","updated_at":"2025-06-15T16:09:12.102Z","avatar_url":"https://github.com/samueljseay.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PageObject\n\n[![Build Status](https://travis-ci.org/samueljseay/page_object.svg?branch=master)](https://travis-ci.org/samueljseay/page_object)\n\nPageObject is a DSL implementing something akin to the\nPage Object pattern for automated testing in Elixir. The API is inspired by [ember-cli-page-object](https://github.com/san650/ember-cli-page-object).\nPageObject currently uses hound but in future may also support other integration testing libraries.\n\nTo find out more about the PageObject pattern check out the [selenium documentation](https://seleniumhq.github.io/docs/best.html#page_object_models).\n\n## Install\n\nInstall PageObject via hex:\n\n`{:page_object, \"~\u003e 0.4.0\"}`\n\nTo use PageObject in your tests you'll still need to setup hound in your test environment. To find out more about that go to the [hound repository](https://github.com/HashNuke/hound).\n\nOnce you have hound and have started a `hound_session` in your test you can use PageObject modules you've defined as in the API examples below.\n\n## API Example\n\n```elixir\n# test/support/pages/dashboard_page.ex\ndefmodule DashboardPage do\n  use PageObject\n\n  visitable :visit, \"http://localhost:4001/account/:account_id/dashboard\"\n\n  clickable :submit, \"input[type='submit']\"\n  clickable :logout, \"button.logout\"\n\n  collection :things, item_scope: \".thing\" do\n    clickable :click, \"button\"\n    value :name_value, \"input[name='name']\"\n  end\n\n  fillable :fill_email, \"input[type='email']\"\n  value :email, \"input[type='email']\"\n\n  def visit_and_submit(account_id) do\n    visit(account_id: account_id, test_param: \"filter\")\n    submit\n  end\n\n  def update_email(email_address) do\n    visit(account_id: account_id, test_param: \"filter\")\n    fill_email(email_address)\n    submit\n  end\nend\n\n# import the module so that actions can be chained together\nimport DashboardPage\n\n# visit http://localhost:4001/account/1/dashboard?test_param=filter\nDashboardPage.visit_and_submit(1)\n\n# or chain actions\nDashboardPage\n|\u003e visit(account_id: 1, test_param: \"filter\")\n|\u003e submit\n\n# visit the page and update a form value\nDashboardPage.update_email(\"newemail@example.com\")\n\n# or chain actions again\nDashboardPage\n|\u003e visit(account_id: 1, test_param: \"filter\")\n|\u003e fill_email(\"newemail@example.com\")\n|\u003e submit\n\n# confirm the value was updated\nassert DashboardPage.email == \"newemail@example.com\"\n\n# useful assertions for urls\nDashboardPage.visit(account_id: 3, test_param: \"filter\")\nassert current_url == DashboardPage.visit_url(account_id: 3, test_param: \"filter\")\n\n# click logout\nDashboardPage.logout\n\n# how many \".thing\" elements are there?\ncount =\n  DashboardPage.Things.all\n  |\u003e Enum.count\n\n# get 0th item from collection of elements and click button on that item\nDashboardPage.Things.get(0)\n|\u003e DashboardPage.Things.click\n\n#get 0th item from collection and query the value of \"input[name='name']\"\nDashboardPage.Things.get(0)\n|\u003e DashboardPage.Things.name_value\n```\n\nFor more API examples see the [tests](https://github.com/samueljseay/page_object/tree/master/test).\n\n### Running the tests\n\nBrowser automation is handled by Hound but you'll also need `phantomjs` installed.\n\n1. `npm install -g phantomjs`\n2. `phantomjs --wd \u003e /dev/null 2\u003e\u00261 \u0026 mix test; killall phantomjs`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamueljseay%2Fpage_object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamueljseay%2Fpage_object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamueljseay%2Fpage_object/lists"}