getElementRect: Return the dimensions and coordinates of an element

Description Usage Arguments Value See Also Examples

Description

getElementRect The getElementRect fuinction returns the dimensions and coordinates of the given web element.

Usage

1
getElementRect(webElem, ...)

Arguments

webElem

An object of class "wElement". A web Element object see wbElement.

...

Additonal function arguments - Currently passes the retry argument.

Value

The returned value is a list including the following members:

x

X axis position of the top-left corner of the web element relative to the current browsing context’s document element in CSS reference pixels.

y

Y axis position of the top-left corner of the web element relative to the current browsing context’s document element in CSS reference pixels.

height

Height of the web element’s bounding rectangle in CSS reference pixels.

width

Width of the web element’s bounding rectangle in CSS reference pixels.

See Also

Other elementState functions: getElementAttribute, getElementCssValue, getElementProperty, getElementTagName, getElementText, isElementEnabled, isElementSelected

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Not run: 
  remDr <- remoteDr()
  remDr %>% go("http://www.google.com/ncr")

  # select the search box
  searchElem <- remDr %>% findElement("name", "q")

  # get the name of our element
  searchElem %>% getElementAttribute("name")

  # get the css background-color
  searchElem %>% getElementCssValue("background-color")
  blueScript <- "arguments[0].style.backgroundColor = 'blue';"
  remDr %>% executeScript(blueScript, list(searchElem))
  searchElem %>% getElementCssValue("background-color")

  # get the javascript property
  # searchElem %>% getElementProperty("backgroundColor")

  # get dimensions
  searchElem %>% getElementRect

  searchElem %>% getElementTagName

  # get some text and return it
  remDr %>% go("http://r-project.org")
  remDr %>% findElement("css", "h1") %>% getElementText

  # close browser
  remDr %>% deleteSession

## End(Not run)

seleniumPipes documentation built on May 2, 2019, 5:57 a.m.