Learn R Programming

seleniumPipes (version 0.3.7)

findElementFromElement: Search for an element on the page, starting from another element

Description

findElementFromElement Search for an element on the page, starting from the node defined by the parent webElement. The located element will be returned as an object of wElement class.

Usage

findElementFromElement(webElem, using = c("xpath", "css selector", "id", "name", "tag name", "class name", "link text", "partial link text"), value, ...)

Arguments

webElem
An object of class "wElement". A web Element object see wbElement.
using
Locator scheme to use to search the element, available schemes: "class name", "css selector", "id", "name", "link text", "partial link text", "tag name", "xpath" . Defaults to 'xpath'. Partial string matching is accepted.
value
The search target. See examples.
...
Additonal function arguments - Currently passes the retry argument.

Value

invisible(wbElement(res$value, webElem$remDr)): An object of class "wElement" is invisibly returned. A webElement object see wbElement. This allows for chaining from this function to other functions that take such an object as an argument. See examples for further details.

Details

Details of possible locator schemes

See Also

Other elementRetrieval functions: findElementsFromElement, findElements, findElement, getActiveElement

Examples

Run this code
## Not run: 
#   remDr <- remoteDr()
#   remDr %>% go("http://www.google.com/ncr")
# 
#   # find the search form query box and search for "R project"
#   webElem <- remDr %>% findElement("name", "q") %>%
#     elementSendKeys("R project", key = "enter")
#   # click the first link hopefully should be www.r-project.org
#   remDr %>% findElement("css", "h3.r a") %>% elementClick
# 
#   # get the navigation div
#   navElem <- remDr %>% findElement("css", "div[role='navigation']")
# 
#   # find all the links in this div
#   navLinks <- navElem %>% findElementsFromElement("css", "a")
# 
#   # check the links
#   nLinks <- sapply(navLinks, function(x) x %>% getElementText)
# 
#   # compare with all links
#   allLinks <- remDr %>% findElements("css", "a")
#   aLinks <- sapply(allLinks, function(x) x %>% getElementText)
# 
#   # show the effect of searching for elements from element
#   aLinks %in% nLinks
# 
#   remDr %>% deleteSession
# ## End(Not run)

Run the code above in your browser using DataLab