Skip to contents

elem_hover() moves the mouse over to an HTML element and hovers over it, without actually clicking or interacting with it.

elem_focus() focuses an HTML element.

Usage

elem_hover(x, js = FALSE, timeout = NULL)

elem_focus(x, timeout = NULL)

Arguments

x

A selenider_element object.

js

Whether to hover over the element using JavaScript.

timeout

How long to wait for the element to exist.

Value

x, invisibly.

See also

Examples

html <- "
<button onmouseover = settext()></button>
<p class = 'text'></p>
"

js <- "
function settext() {
  const element = document.getElementsByClassName('text').item(0);

  element.innerHTML = 'Button hovered!';
}
"

session <- minimal_selenider_session(html, js = js)

elem_expect(s(".text"), has_exact_text(""))

s("button") |>
  elem_hover()

elem_expect(s(".text"), has_text("Button hovered!"))

s("button") |>
  elem_focus()