wallaby v0.1.0 Wallaby.Session

Common functionality for interacting with Sessions.

Sessions are used to represent a user navigating through and interacting with different pages.

Fields

  • id - The session id generated from the webdriver
  • base_url - The base url for the application under test.
  • server - The specific webdriver server that the session is running in.

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:

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

  {:ok, user2} = Wallaby.start_session
  user2
  |> visit("/page.html")
  |> fill_in("Share Message", with: "Hello yourself")
  |> click_on("Share")

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

Summary

Functions

Clicks the matching link. Links can be found based on id, name, or link text

Gets the size of the session’s window

Sets the size of the sessions window

Takes a screenshot of the current window. Screenshots are saved to a “screenshots” directory in the same directory the tests are run in

Changes the current page to the provided route. Routes are relative to any base url provided

Types

t :: %Wallaby.Session{base_url: String.t, id: integer, server: pid}

Functions

click_link(session, link)

Specs

click_link(t, String.t) :: t

Clicks the matching link. Links can be found based on id, name, or link text.

get_window_size(session)

Specs

get_window_size(t) :: %{String.t => pos_integer, String.t => pos_integer}

Gets the size of the session’s window.

set_window_size(session, width, height)

Specs

set_window_size(t, pos_integer, pos_integer) :: t

Sets the size of the sessions window.

take_screenshot(node)

Specs

take_screenshot(t) :: %{session: t, path: String.t}

Takes a screenshot of the current window. Screenshots are saved to a “screenshots” directory in the same directory the tests are run in.

visit(session, path)

Specs

visit(t, String.t) :: t

Changes the current page to the provided route. Routes are relative to any base url provided.