Elixir library to help selecting the right elements in your tests.
Switch branches/tags
Clone or download
Latest commit 4c95880 Jul 21, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci use phantomjs instead of selenium Jul 19, 2017
config setup the browser tests Jul 19, 2017
lib Add search_test_element helper Jul 20, 2017
rel initial commit Jul 14, 2017
script setup the browser tests Jul 19, 2017
test Add missing tests Jul 20, 2017
.gitignore initial commit Jul 14, 2017
LICENSE Create LICENSE Jul 18, 2017
README.md Merge pull request #14 from DefactoSoftware/marcel/readme-badge Jul 21, 2017
mix.exs Bump to v0.2.0 Jul 20, 2017
mix.lock setup the browser tests Jul 19, 2017


Hex.pm CircleCI


A set of Elixir and Hound helpers to set/get test selectors to/from elements in a Phoenix app (when Mix.env == :test). These selectors are hashed (scoped to the view module they are used in) for accurate selection and "leakage" prevention. See our Wiki for examples.

Why? Because we prefer reserving classes for styling, and id's have limitations because they have to be unique.



def deps do
  [{:test_selector, "~> 0.2.0"}]

Use TestSelector.HTML.Helpers to your web.ex.

  • In phoenix 1.2.0 at web/web.ex
  • In phoenix 1.3.0 and up at lib/your_project/web/web.ex

Add somewhere along:

  def view(opts \\ []) do
    quote do
      use Phoenix.HTML

      use TestSelector.HTML.Helpers

In the tests import the TestSelector.Test.Helpers:

defmodule Project.Web.MyTest do
  use Hound.Helpers

  import TestSelector.Test.Helpers


To run tests you need to install PhantomJS.

brew install phantomjs

Run the webdriver:

phantomjs -w

Run the tests:

mix test