Wallaby.Selenium (wallaby v0.28.0) View Source

The Selenium driver uses Selenium Server to power many types of browsers (Chrome, Firefox, Edge, etc).

Usage

Start a Wallaby Session using this driver with the following command:

{:ok, session} = Wallaby.start_session()

Configuration

Capabilities

These capabilities will override the default capabilities.

config :wallaby,
  selenium: [
    capabilities: %{
      # something
    }
  ]

Default Capabilities

By default, Selenium will use the following capabilities

You can read more about capabilities in the JSON Wire Protocol documentation.

%{
  javascriptEnabled: true,
  browserName: "firefox",
  "moz:firefoxOptions": %{
    args: ["-headless"]
  }
}

Notes

  • Requires selenium-server-standalone to be running on port 4444. Wallaby does not manage the start/stop of the Selenium server.
  • Requires GeckoDriver to be installed in your path when using Firefox. Firefox is used by default.

Link to this section Summary

Types

Options to pass to Wallaby.start_session/1

Functions

Returns a specification to start this module under a supervisor.

Simulates typing into an element.

Link to this section Types

Specs

start_session_opts() :: {:remote_url, String.t()} | {:capabilities, map()}

Options to pass to Wallaby.start_session/1

Wallaby.start_session(
  remote_url: "http://selenium_url",
  capabilities: %{browserName: "firefox"}
)

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

element_location(element)

View Source
Link to this function

send_keys(session, keys)

View Source

Specs

send_keys(Wallaby.Session.t() | Wallaby.Element.t(), list()) :: {:ok, any()}

Simulates typing into an element.

When sending keys to an element and keys is identified as a local file, the local file is uploaded to the Selenium server, returning a file path which is then set to the file input we are interacting with.

We then call the WebdriverClient.send_keys/2 to set the remote file path as the input's value.