const classafBounce::Element
sys::Obj afBounce::Element
(HTML Element) Represents a generic HTML element.
- cssClass
Str? cssClass()
Returns the
class
attribute as declared by the element, otherwisenull
.- elementName
Str elementName()
Returns the name of the the element. e.g.
div
The method
name()
is reserved for thename
attribute of form inputs.- exists
Bool exists()
Returns
true
if this element exists.- find
Finds elements inside this element.
- getAtIndex
@
Operator
This getAtIndex(Int index)Returns the element of the current selection at the specified index. Use -1 to select from the end of the list.
Example using the operator shortcut:
value := element[-2]
Note this method is safe and does NOT throw an Err should the index be out of bounds. (Although subsequent method calls on the returned object would fail.) Instead use
verifyDoesNotExist()
.Also note that this returns different results to the CSS selector
:nth-child
.- getAttr
@
Operator
Str? getAttr(Str name)Returns the value of the named attribute. Returns
null
if it does not exist.Example using the operator shortcut:
attrVal := element["attrName"]
- hasAttr
Returns
true
if the element defines the given attribute, regardless of its value.- hasCssClass
Returns
true
if the class attribute contains the given value.The match is done on a whitespace split of the class attribute and is case insensitive.
- html
Str html()
Returns the markup generated by this node, including the element itself.
- id
Str? id()
Returns the
id
attribute as declared by the element. Returnsnull
if the element does not have anid
attribute.- innerHtml
Str innerHtml()
Returns the markup generated by the children of this node.
- list
Element[] list()
Return all elements as a list.
- makeFromCss
new makeFromCss(Str cssSelector)
- size
Int size()
Returns the number of elements found by the selector
- submitForm
virtual ButterResponse submitForm()
Submits an enclosing form to Bed App.
- text
Str text()
Returns the text content of this element and it's child elements.
- toCheckBox
CheckBox toCheckBox()
Returns this element as a CheckBox
- toFormInput
FormInput toFormInput()
Returns this element as a FormInput
- toHidden
Hidden toHidden()
Returns this element as a Hidden input
- toLink
Link toLink()
Returns this element as a Link
- toOption
Option toOption()
Returns this element as an Option
- toRadioButton
RadioButton toRadioButton()
Returns this element as a RadioButton input.
- toSelectBox
SelectBox toSelectBox()
Returns this element as a SelectBox
- toStr
virtual override Str toStr()
Returns the complete CSS selector and the resulting HTML.
- toSubmitButton
SubmitButton toSubmitButton()
Returns this element as a SubmitButton
- toTextBox
TextBox toTextBox()
Returns this element as a TextBox
- verifyAttrEq
Void verifyAttrEq(Str attrName, Obj expected)
Verify that the element has the given attribute value.
- verifyAttrExists
Void verifyAttrExists(Str attrName)
Verify that the element defines the given attribute, regardless of value.
- verifyCssClassContains
Void verifyCssClassContains(Obj expected)
Verify that the current selection has the given size.
- verifyDoesNotExist
Void verifyDoesNotExist()
Verify that the current selection heralds no elements, otherwise throw a test failure exception.
- verifyExists
Void verifyExists()
Verify that at least one element is selected from the document, otherwise throw a test failure exception.
- verifySizeEq
Void verifySizeEq(Int expectedSize)
Verify that the current selection has the given size.
- verifyTextContains
Void verifyTextContains(Obj contains)
Verify that the element text contains the given str. The match is case insensitive.
- verifyTextEq
Void verifyTextEq(Obj expected)
Verify that the given text matches the text of the element. The match is case insensitive.
- xelem
XElem? xelem(Bool checked := true)
Returns the first
XElem
object.Returns
null
ifchecked
isfalse
and no elements are found. Always throws an Err is multiple elements are returned.- xelems
XElem[] xelems()
Returns a list of underlying
XElem
objects. The list may be empty.