# PageObjects pattern for e2e testing - And packages yet?

**URL:** <https://forum.elixirforum.com/t/pageobjects-pattern-for-e2e-testing-and-packages-yet/60313>\
**Category:** Questions\
**Tags:** wallaby, phoenix, testing\
**Created:** [December 12, 2023, 1:29pm UTC](https://forum.elixirforum.com/t/pageobjects-pattern-for-e2e-testing-and-packages-yet/60313 "2023-12-12T13:29:41Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![al2o3cr](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/32/3457_2.png) [@al2o3cr](https://forum.elixirforum.com/u/al2o3cr)\
**Post date:** [December 12, 2023, 5:24pm UTC](https://forum.elixirforum.com/t/pageobjects-pattern-for-e2e-testing-and-packages-yet/60313/2 "2023-12-12T17:24:07Z")

</div>

I haven’t used a library for this in Elixir, but it’s possible to get similar expressiveness with just functions using tools like [`Phoenix.LiveViewTest.element`](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveViewTest.html#element/3)

You’d write a helper function like:

```elixir
def shiny_magic_button(view, name_filter \\ nil) do
  element(view, "button.shiny.magic", name_filter)
end

```

Then you could write assertions like:

```elixir
assert view
       |> shiny_magic_button(~r{[wat]+})
       |> render_focus() =~ "Some message"

```

Alternatively, I’ve also written helpers that took arguments and build a large “selector”, since functions like `has_element?` expect that.

---

_[View the full topic](https://forum.elixirforum.com/t/pageobjects-pattern-for-e2e-testing-and-packages-yet/60313)._
