Skip to contents

Find every available HTML element using a CSS selector, an XPath, or a variety of other methods.

Usage

find_elements(x, ...)

# S3 method for class 'selenider_session'
find_elements(
  x,
  css = NULL,
  xpath = NULL,
  id = NULL,
  class_name = NULL,
  name = NULL,
  ...
)

# S3 method for class 'selenider_element'
find_elements(
  x,
  css = NULL,
  xpath = NULL,
  id = NULL,
  class_name = NULL,
  name = NULL,
  ...
)

Arguments

x

A selenider session or element.

...

Arguments passed to methods.

css

A css selector.

xpath

An XPath.

id

The id of the element you want to select.

class_name

The class name of the element you want to select.

name

The name attribute of the element you want to select.

Value

A selenider_elements object. Note that this is not a list, and you should be careful with the functions that you use with it. See the advanced usage vignette for more details: vignette("advanced-usage", package = "selenider").

Details

If more than one method is used to select an element (e.g. css and xpath), the first element which satisfies every condition will be found.

See also

Examples

html <- "
<div id='outer-div'>
  <div>
    <p>Text 1</p>
    <p>Text 2</p>
    <p>Text 3</p>
  </div>
</div>

<div></div>
"

session <- minimal_selenider_session(html)

session |>
  find_elements("div")

# Or:
ss("div")

session |>
  find_element("#outer-div") |>
  find_elements("p")

# The above can be shortened to:
s("#outer-div") |>
  find_elements("p")