butterbee/get

The action module contains functions to get elements from the DOM

Usage

After navigating to a page, call one of the functions in this module to get a node, or a list of nodes. After getting a node, you can perform actions on it using functions from the node and action modules. Butterbee supports different locating strategies, see the by module for more information.

Example

This example gets a node from the page, and then performs an action on it:

let example =
  driver
  // navigate to a page
  |> driver.goto("https://gleam.run/")
  // get the node matching the css selector `a.logo` 
  // and adds it to the state of the webdriver
  |> get.node(by.css("a.logo"))
  // perform actions on the node that was queried above
  |> node.get(node.text()) 

getting nodes directly is useful for one-off situations, but if you want to make your tests more reusable, its recommended to use page modules.

Values

pub fn from_node(
  driver: webdriver.WebDriver(remote_value.NodeRemoteValue),
  locator: locator.Locator,
) -> webdriver.WebDriver(remote_value.NodeRemoteValue)

Finds a node matching the given locator starting from the node in state.

pub fn node(
  driver: webdriver.WebDriver(state),
  locator: locator.Locator,
) -> webdriver.WebDriver(remote_value.NodeRemoteValue)

Finds a node matching the given locator. If multiple nodes are found, the first node is returned.

pub fn node_from_nodes(
  driver: webdriver.WebDriver(List(remote_value.NodeRemoteValue)),
  index: Int,
) -> webdriver.WebDriver(remote_value.NodeRemoteValue)

Finds a node matching the given index starting from the list of nodes in state.

pub fn nodes(
  driver: webdriver.WebDriver(state),
  locator: locator.Locator,
) -> webdriver.WebDriver(List(remote_value.NodeRemoteValue))

Finds all nodes matching the given locator.

pub fn nodes_from_node(
  driver: webdriver.WebDriver(remote_value.NodeRemoteValue),
  locator: locator.Locator,
) -> webdriver.WebDriver(List(remote_value.NodeRemoteValue))

Finds a list of nodes matching the given locator starting from the node in state.

Search Document