| elem_scroll_to | R Documentation | 
Scrolls to an HTML element.
elem_scroll_to(x, js = FALSE, timeout = NULL)
x | 
 A   | 
js | 
 Whether to scroll to the element using JavaScript.  | 
timeout | 
 How long to wait for the element to exist.  | 
x, invisibly.
Other actions: 
elem_click(),
elem_hover(),
elem_select(),
elem_set_value(),
elem_submit()
html <- "
<div style = 'height:100%; min-height:100vh'></div>
<button onclick='checkScrolled()'></button>
<p>Scroll down to find me!</p>
"
js <- "
function checkScrolled() {
  let element = document.getElementsByTagName('p').item(0);
  let rect = element.getBoundingClientRect();
  // If paragraph is in view
  const height = window.innerHeight || document.documentElement.clientHeight;
  if (rect.bottom <= height) {
    element.innerText = 'You found me!';
  }
}
"
session <- minimal_selenider_session(html, js = js)
s("p") |>
  elem_scroll_to()
s("button") |>
  elem_click()
elem_expect(s("p"), has_text("You found me!"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.