wallaby v0.17.0 Wallaby

A concurrent feature testing library.

Configuration

Wallaby supports the following options:

  • :pool_size - Maximum amount of phantoms to run. The default is :erlang.system_info(:schedulers_online) * 2.
  • :screenshot_dir - The directory to store screenshots.
  • :screenshot_on_failure - if Wallaby should take screenshots on test failures (defaults to false).
  • :max_wait_time - The amount of time that Wallaby should wait to find an element on the page. (defaults to 3_000)
  • :js_errors - if Wallaby should re-throw javascript errors in elixir (defaults to true).
  • :js_logger - IO device where javascript console logs are written to. Defaults to :stdio. This option can also be set to a file or any other io device. You can disable javascript console logging by setting this to nil.
  • :phantomjs - The path to the phantomjs executable (defaults to “phantomjs”)
  • :phantomjs_args - Any extra arguments that should be passed to phantomjs (defaults to “”)

Summary

Functions

Ends a browser session

Starts a browser session

Types

reason()
reason() :: any
start_session_opts()
start_session_opts() :: {:driver, module} | {atom, any}

Functions

end_session(session)
end_session(Wallaby.Session.t) ::
  {:ok, Wallaby.Session.t} |
  {:error, reason}

Ends a browser session.

start_session(opts \\ [])
start_session([start_session_opts]) ::
  {:ok, Wallaby.Session.t} |
  {:error, reason}

Starts a browser session.

Multiple sessions

Each session runs in its own browser so that each test runs in isolation. Because of this isolation multiple sessions can be created for a test:

@message_field Query.text_field("Share Message")
@share_button Query.button("Share")
@message_list Query.css(".messages")

test "That multiple sessions work" do
  {:ok, user1} = Wallaby.start_session
  user1
  |> visit("/page.html")
  |> fill_in(@message_field, with: "Hello there!")
  |> click(@share_button)

  {:ok, user2} = Wallaby.start_session
  user2
  |> visit("/page.html")
  |> fill_in(@message_field, with: "Hello yourself")
  |> click(@share_button)

  assert user1 |> find(@message_list) |> List.last |> text == "Hello yourself"
  assert user2 |> find(@message_list) |> List.first |> text == "Hello there"
end