All Projects → samueljseay → page_object

samueljseay / page_object

Licence: MIT license
Page Objects for Hound / Elixir

Programming Languages

elixir
2628 projects
HTML
75241 projects

Projects that are alternatives of or similar to page object

Elixirbooks
List of Elixir books
Stars: ✭ 1,021 (+5273.68%)
Mutual labels:  elixir-phoenix
Adoptoposs
Finding co-maintainers for your open source software project.
Stars: ✭ 93 (+389.47%)
Mutual labels:  elixir-phoenix
Statuspal
Statuspal lets you communicate your web apps/services status 📡
Stars: ✭ 179 (+842.11%)
Mutual labels:  elixir-phoenix
Phoenix Ecto Append Only Log Example
📝 A step-by-step example/tutorial showing how to build a Phoenix (Elixir) App where all data is immutable (append only). Precursor to Blockchain, IPFS or Solid!
Stars: ✭ 58 (+205.26%)
Mutual labels:  elixir-phoenix
Loki
📝 Loki is library that includes helpers for building powerful interactive command line applications, tasks, modules.
Stars: ✭ 71 (+273.68%)
Mutual labels:  elixir-phoenix
Bamboo
Testable, composable, and adapter based Elixir email library for devs that love piping.
Stars: ✭ 1,756 (+9142.11%)
Mutual labels:  elixir-phoenix
Drab
Remote controlled frontend framework for Phoenix.
Stars: ✭ 833 (+4284.21%)
Mutual labels:  elixir-phoenix
EggSeed
Command Line Tool for Starting Your Swift Packages with Continuous Integration
Stars: ✭ 21 (+10.53%)
Mutual labels:  hound
Ecto morph
morph your Ecto capabilities into the s t r a t o s p h e r e !
Stars: ✭ 72 (+278.95%)
Mutual labels:  elixir-phoenix
Short url
🔗 short url app elixir Phoenix
Stars: ✭ 162 (+752.63%)
Mutual labels:  elixir-phoenix
Phoenix In Action
Code snippets and examples from the book Phoenix in Action from Manning and Geoffrey Lessel
Stars: ✭ 60 (+215.79%)
Mutual labels:  elixir-phoenix
Firebird
Template for Phoenix 1.3 projects
Stars: ✭ 66 (+247.37%)
Mutual labels:  elixir-phoenix
Veil
Simple passwordless authentication for your Phoenix apps
Stars: ✭ 153 (+705.26%)
Mutual labels:  elixir-phoenix
Elixirconf 2018
A collection of links that cover what happened during ElixirConf 2018 🐥 🔥. Please feel free to submit a PR!
Stars: ✭ 56 (+194.74%)
Mutual labels:  elixir-phoenix
versionary
Plug for API versioning
Stars: ✭ 40 (+110.53%)
Mutual labels:  elixir-phoenix
Cog
Bringing the power of the command line to chat
Stars: ✭ 910 (+4689.47%)
Mutual labels:  elixir-phoenix
Scrivener html
HTML view helpers for Scrivener
Stars: ✭ 112 (+489.47%)
Mutual labels:  elixir-phoenix
live dj
💿 Join or create video playlists to share a real-time experience with others! 🎧
Stars: ✭ 19 (+0%)
Mutual labels:  elixir-phoenix
freshcom-api
Deprecated
Stars: ✭ 43 (+126.32%)
Mutual labels:  elixir-phoenix
Docker Phoenix
A dockerized Phoenix development and runtime environment.
Stars: ✭ 152 (+700%)
Mutual labels:  elixir-phoenix

PageObject

Build Status

PageObject is a DSL implementing something akin to the Page Object pattern for automated testing in Elixir. The API is inspired by ember-cli-page-object. PageObject currently uses hound but in future may also support other integration testing libraries.

To find out more about the PageObject pattern check out the selenium documentation.

Install

Install PageObject via hex:

{:page_object, "~> 0.4.0"}

To 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.

Once 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.

API Example

# test/support/pages/dashboard_page.ex
defmodule DashboardPage do
  use PageObject

  visitable :visit, "http://localhost:4001/account/:account_id/dashboard"

  clickable :submit, "input[type='submit']"
  clickable :logout, "button.logout"

  collection :things, item_scope: ".thing" do
    clickable :click, "button"
    value :name_value, "input[name='name']"
  end

  fillable :fill_email, "input[type='email']"
  value :email, "input[type='email']"

  def visit_and_submit(account_id) do
    visit(account_id: account_id, test_param: "filter")
    submit
  end

  def update_email(email_address) do
    visit(account_id: account_id, test_param: "filter")
    fill_email(email_address)
    submit
  end
end

# import the module so that actions can be chained together
import DashboardPage

# visit http://localhost:4001/account/1/dashboard?test_param=filter
DashboardPage.visit_and_submit(1)

# or chain actions
DashboardPage
|> visit(account_id: 1, test_param: "filter")
|> submit

# visit the page and update a form value
DashboardPage.update_email("[email protected]")

# or chain actions again
DashboardPage
|> visit(account_id: 1, test_param: "filter")
|> fill_email("[email protected]")
|> submit

# confirm the value was updated
assert DashboardPage.email == "[email protected]"

# useful assertions for urls
DashboardPage.visit(account_id: 3, test_param: "filter")
assert current_url == DashboardPage.visit_url(account_id: 3, test_param: "filter")

# click logout
DashboardPage.logout

# how many ".thing" elements are there?
count =
  DashboardPage.Things.all
  |> Enum.count

# get 0th item from collection of elements and click button on that item
DashboardPage.Things.get(0)
|> DashboardPage.Things.click

#get 0th item from collection and query the value of "input[name='name']"
DashboardPage.Things.get(0)
|> DashboardPage.Things.name_value

For more API examples see the tests.

Running the tests

Browser automation is handled by Hound but you'll also need phantomjs installed.

  1. npm install -g phantomjs
  2. phantomjs --wd > /dev/null 2>&1 & mix test; killall phantomjs
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].