Find every available HTML element using a CSS selector, an XPath, or a variety of other methods.
Usage
find_elements(x, ...)
# S3 method for selenider_session
find_elements(
x,
css = NULL,
xpath = NULL,
id = NULL,
class_name = NULL,
name = NULL,
...
)
# S3 method for 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.
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
ss()
to quickly select multiple elements without specifying the session.find_element()
to select multiple elements.selenider_session()
to begin a session.elem_children()
and family to select elements using their relative position in the DOM.elem_filter()
andelem_find()
for filtering element collections.
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")