s | R Documentation |
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()
.
s(css = NULL, xpath = NULL, id = NULL, class_name = NULL, name = NULL)
ss(css = NULL, xpath = NULL, id = NULL, class_name = NULL, name = NULL)
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. |
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.
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")
.
find_element()
and find_elements()
selenider_session()
to begin a session.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.