s {selenider}R Documentation

Select HTML elements

Description

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)

Arguments

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

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.

Value

s() returns a selenider_element object. ss() returns a selenider_elements object.

See Also

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")


[Package selenider version 0.4.0 Index]