const classafBounce::Element
sys::Obj afBounce::Element
(HTML Element) Represents a generic HTML element.
Str? cssClass()
Returns the
class
attribute as declared by the element, otherwisenull
.Str elementName()
Returns the name of the the element. e.g.
div
The method
name()
is reserved for thename
attribute of form inputs.Bool exists()
Returns
true
if this element exists.Finds elements inside this element.
@
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
.@
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"]
Returns
true
if the element defines the given attribute, regardless of its value.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.
Str html()
Returns the markup generated by this node, including the element itself.
Str? id()
Returns the
id
attribute as declared by the element. Returnsnull
if the element does not have anid
attribute.Str innerHtml()
Returns the markup generated by the children of this node.
Element[] list()
Return all elements as a list.
new makeFromCss(Str cssSelector)
Int size()
Returns the number of elements found by the selector
virtual ButterResponse submitForm()
Submits an enclosing form to Bed App.
Str text()
Returns the text content of this element and it's child elements.
CheckBox toCheckBox()
Returns this element as a CheckBox
FormInput toFormInput()
Returns this element as a FormInput
Hidden toHidden()
Returns this element as a Hidden input
Link toLink()
Returns this element as a Link
Option toOption()
Returns this element as an Option
RadioButton toRadioButton()
Returns this element as a RadioButton input.
SelectBox toSelectBox()
Returns this element as a SelectBox
virtual override Str toStr()
Returns the complete CSS selector and the resulting HTML.
SubmitButton toSubmitButton()
Returns this element as a SubmitButton
TextBox toTextBox()
Returns this element as a TextBox
Void verifyAttrEq(Str attrName, Obj expected)
Verify that the element has the given attribute value.
Void verifyAttrExists(Str attrName)
Verify that the element defines the given attribute, regardless of value.
Void verifyCssClassContains(Obj expected)
Verify that the current selection has the given size.
Void verifyDoesNotExist()
Verify that the current selection heralds no elements, otherwise throw a test failure exception.
Void verifyExists()
Verify that at least one element is selected from the document, otherwise throw a test failure exception.
Void verifySizeEq(Int expectedSize)
Verify that the current selection has the given size.
Void verifyTextContains(Obj contains)
Verify that the element text contains the given str. The match is case insensitive.
Void verifyTextEq(Obj expected)
Verify that the given text matches the text of the element. The match is case insensitive.
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.XElem[] xelems()
Returns a list of underlying
XElem
objects. The list may be empty.