R: HTML element

Element {webdriver} | R Documentation

## HTML element

### Description

HTML element

### Usage

    e <- s$findElement(css = NULL, linkText = NULL,
        partialLinkText = NULL, xpath = NULL)

    e$findElement(css = NULL, linkText = NULL,
        partialLinkText = NULL, xpath = NULL)
    e$findElements(css = NULL, linkText = NULL,
        partialLinkText = NULL, xpath = NULL)

    e$isSelected()
    e$getValue()
    e$setValue(value)
    e$getAttribute(name)
    e$getClass()
    e$getCssValue(name)
    e$getText()
    e$getName()
    e$getData(name)
    e$getRect()
    e$isEnabled()
    e$click()
    e$clear()
    e$sendKeys(...)
    e$moveMouseTo(xoffset = NULL, yoffset = NULL)

    e$executeScript(script, ...)
    e$executeScriptAsync(script, ...)

### Arguments

e

  An `Element` object.

s

  A `Session` object.

css

  Css selector to find an HTML element.

linkText

  Find `<a>` HTML elements based on their `innerText`.

partialLinkText

  Find `<a>` HTML elements based on their `innerText`. It uses partial matching.

xpath

  Find HTML elements using XPath expressions.

name

  String scalar, named of attribute, property or css key. For `getData`, the key of the data attribute.

xoffset

  Horizontal offset for mouse movement, relative to the position of the element. If at least of of `xoffset` and `yoffset` is `NULL`, then they are ignored.

yoffset

  Vertical offset for mouse movement, relative to the position of the element. If at least of of `xoffset` and `yoffset` is `NULL`, then they are ignored.

value

  Value to set, a character string.

...

  For `sendKeys` the keys to send, see `key`. For `executeScript` and `executeScriptAsync` argument to supply to the script.

### Details

To create `Element` objects, you need to use the `findElement` (or `findElement`) method of a `Session` object.

`e$findElement()` finds the next HTML element from the current one. You need to specify one of the `css`, `linkText`, `partialLinkText` and `xpath` arguments. It returns a new `Element` object.

`e$findElements()` finds all matching HTML elements starting from the current element. You need to specify one of the `css`, `linkText`, `partialLinkText` and `xpath` arguments. It returns a list of newly created `Element` objects.

`e$isSelected()` returns `TRUE` is the element is currently selected, and `FALSE` otherwise.

`e$getValue()` returns the value of an input element, it is a shorthand for `e$getAttribute("value")`.

`e$setValue()` sets the value of an input element, it is essentially equivalent to sending keys via `e$sendKeys()`.

`e$getAttribute()` queries an arbitrary HTML attribute. It is does not exist, `NULL` is returned.

`e$getClass()` uses `e$getAttribute` to parse the ‘class’ attribute into a character vector.

`e$getCssValue()` queries a CSS property of an element.

`e$getText()` returns the `innerText` on an element.

`e$getName()` returns the tag name of an element.

`e$getData()` is a shorthand for querying `data-*` attributes.

`e$getRect()` returns the ‘rectangle’ of an element. It is named list with components `x`, `y`, `height` and `width`.

`e$isEnabled()` returns `TRUE` if the element is enabled, `FALSE` otherwise.

`e$click()` scrolls the element into view, and clicks the in-view centre point of it.

`e$clear()` scrolls the element into view, and then attempts to clear its value, checkedness or text content.

`e$sendKeys()` scrolls the form control element into view, and sends the provided keys to it. See `key` for a list of special keys that can be sent.

`e$uploadFile()` uploads a file to a `<input type="file">` element. The `filename` argument can contain a single filename, or multiple filenames, for file inputs that can take multiple files.

`e$moveMouseTo()` moves the mouse cursor to the element, with the specified offsets. If one or both offsets are `NULL`, then it places the cursor on the center of the element. If the element is not on the screen, then is scrolls it into the screen first.

`e$executeScript()` and `e$executeScriptAsync()` call the method of the same name on the `Session` object. The first argument of the script (`arguments[0]`) will always hold the element object itself.

[Package webdriver version 1.0.5 Index]