Learn R Programming

relenium (version 0.3.0)

webElementClass: Class webElementClass. A class to represent a web element

Description

This class is designed to represent a web element and interact with it.

Arguments

Fields

keys:
This is a list of the available keys that can be used in the 'sendKeys' method. They refer to keys of the keyboard.

Methods

Navigation and web data extraction
clear():
If this element is a text entry element, this will clear the value.
click():
Click this element.
getAllAttributes():
All the attributes from the selected tag.
getAttribute(stringName = ""):
Get the value of a given attribute of the element.
getCssValue(stringName = ""):
Get the value of a given CSS property.
getHtml(tagLine = TRUE):
Get the inner html code of this element. If tagLine = TRUE, the code includes the tag line code.
getId():
Get the id of this element. Returns a character.
getSize():
Returns a vector with the height and the width (in this order) of the rendered element.
getTagName():
Get the tag name of this element.
getText():
Get the visible text
printHtml(tagLine = TRUE):
Parse and print the inner html code of this element. It is like getHtml but it returns the html code in a more readable form. If tagLine = TRUE, the code includes the tag line code.
isDisplayed():
Whether this element is displayed or not.
isEnabled():
Whether the element is currently enabled or not. This will generally return true for everything but disabled input elements
isSelected():
Determine whether this element is selected or not. This operation only applies to input elements such as checkboxes, options in a select and radio buttons. It returns True if the element is currently selected or checked, or false otherwise.
sendKeys(text = NULL, keys = ""):
Use this method to simulate typing into an element, which may set its value. The argument text should be a character.
submit():
If this current element is a form or an element within a form, then this will be submitted to the remote server.
Select methods These apply to web elements with tag 'select'.
isMultiple():
Whether this select element supports selecting multiple options at the same time or not. This is done by checking the value of the "multiple" attribute.
getOptions():
Use this method to get all options belonging to this select tag. Returns a list of webElementClass objects.
getAllSelectedOptions:
All selected options belonging to this select tag. Returns a list of webElementClass objects.
getFirstSelectedOption():
The first selected option in this select tag (or the currently selected option in a normal select. Returns a webElementClass object.)
selectByVisibleText(stringName = ""):
Select all options that display text matching the argument. That is, when given "Bar" this would select an option like:
selectByIndex(ind = 1):
Select the option at the given index. This is done by examining the "index" attribute of an element, and not merely by counting.
selectByValue(stringName = ""):
Select all options that have a value matching the argument. That is, when given "foo" this would select an option like:
deselectAll():
Clear all selected entries. This is only valid when SELECT supports multiple selections.
deselectByIndex(ind = 1):
Deselect the option at the given index. This is done by examining the "index" attribute of an element, and not merely by counting.
deselectByValue(stringName = ""):
Deselect all options that have a value matching the argument. That is, when given "foo" this would deselect an option like:
deselectByVisibleText(stringName = ""):
Deselect all options that display text matching the argument. That is, when given "Bar" this would deselect an option like:
Locating elements There are different methods to find a single element in a page. All the functions from the 'findElement/s' family have the same argument stringName = "". Functions of type 'finElement' return a webElementClass object. Functions of type 'finElements' return a list of webElementClass objects.
findElementByXPath:
Use this method when you know the xpath of an element. With this strategy, the first element matching the xpath will be returned.
findElementByClassName:
Use this method when you know the class attribute of an element. With this strategy, the first element with the class attribute value matching the location will be returned.
findElementByCssSelector:
Use this method to find elements via the driver's underlying W3 Selector engine. If the browser does not implement the Selector API, a best effort is made to emulate the API.
findElementById:
Use this method when you know the id attribute of an element. With this strategy, the first element with the id attribute value matching the location will be returned.
findElementByName:
Use this method when you know the name attribute of an element. With this strategy, the first element with the name attribute value matching the location will be returned.
findElementByLinkText:
Use this method when you know text of an element. With this strategy, the first element matching the exact text will be returned.
findElementByPartialLinkText:
Use this method when you know the text of an element. With this strategy, the first element matching the partial text will be returned.
findElementByTagName:
Use this method when you know the tag name of an element. With this strategy, the first element matching the tag name will be returned.
To find multiple elements use the following methods in the same way as the previous ones. Note that these methods will return a list.
  • findElementsByXPath
  • findElementsByClassName
  • findElementsByCssSelector
  • findElementsById
  • findElementByPartialLinkText
  • findElementsByLinkText
  • findElementsByName
  • findElementsByPartialLinkText
  • findElementsByTagName

Details

The webElement class is implemented as a reference class (see ReferenceClasses for more details). This class is designed to represent a web element and interact with it. It represents an HTML element. Generally, all interesting operations to do when interacting with a page will be performed through this interface. You get a webElementClass from firefoxClass find methods or from other webElementClass. With this class you can navigate, select, extract web data and find web elements. All methods implemented are explained below. Documentation is based on the original Selinum's Java documentation. It is possible to access to the methods through TAB completion. An example of webElementClass can be found using demo(package = "relenium").

See Also

ReferenceClasses, relenium-package, firefoxClass