View Source Wallaby.Selenium (wallaby v0.30.6)

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

usage

Usage

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

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

configuration

Configuration

capabilities

Capabilities

These capabilities will override the default capabilities.

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

selenium-remote-url

Selenium Remote URL

It is possible to globally set Selenium's "Remote URL" by setting the following option.

By default it is http://localhost:4444/wd/hub/

config :wallaby,
  selenium: [
    remote_url: "http://selenium_url"
  ]

default-capabilities

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

Notes

  • Requires selenium-server 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

@type 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
@spec 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.