Both s()
and ss()
allow you to select elements without specifying a
session object.
s()
selects a single element, being a shorthand for find_element()
on the current session.
ss()
selects multiple elements, being a shorthand for find_elements()
.
Usage
s(css = NULL, xpath = NULL, id = NULL, class_name = NULL, name = NULL)
ss(css = NULL, xpath = NULL, id = NULL, class_name = NULL, name = NULL)
Value
s()
returns a selenider_element
object.
ss()
returns 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
Both functions allow the starting point for chains of selectors to be made
more concise. Both use get_session()
to get the global session object.
If you want to pass in a session, use find_element()
/find_elements()
instead.
See also
selenider_session()
to begin a session.
Examples
html <- "
<div>
<p id='id1' class='inner'></p>
<div class='child'>
<p class='inner'></p>
</div>
</div>
"
session <- minimal_selenider_session(html)
s("#id1")
# This is the equivalent of:
find_element(session, "#id1")
ss(".inner")
# This is the equivalent of:
find_element(session, ".inner")
# This provides a more concise way to begin a chain of selectors
s("div") |>
find_element(".child") |>
find_element(".inner")