const classafBounce::Element

sys::Obj
  afBounce::Element

(HTML Element) Represents a generic HTML element.

cssClass

Source

Str? cssClass()

Returns the class attribute as declared by the element, otherwise null.

elementName

Source

Str elementName()

Returns the name of the the element. e.g. div

The method name() is reserved for the name attribute of form inputs.

exists

Source

Bool exists()

Returns true if this element exists.

find

Source

Element find(Str cssSelector)

Finds elements inside this element.

getAtIndex

Source

@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

Source

@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

Source

Bool hasAttr(Str value)

Returns true if the element defines the given attribute, regardless of its value.

hasCssClass

Source

Bool hasCssClass(Str 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.

html

Source

Str html()

Returns the markup generated by this node, including the element itself.

id

Source

Str? id()

Returns the id attribute as declared by the element. Returns null if the element does not have an id attribute.

innerHtml

Source

Str innerHtml()

Returns the markup generated by the children of this node.

list

Source

Element[] list()

Return all elements as a list.

makeFromCss

Source

new makeFromCss(Str cssSelector)

size

Source

Int size()

Returns the number of elements found by the selector

submitForm

Source

virtual ButterResponse submitForm()

Submits an enclosing form to Bed App.

text

Source

Str text()

Returns the text content of this element and it's child elements.

toCheckBox

Source

CheckBox toCheckBox()

Returns this element as a CheckBox

toFormInput

Source

FormInput toFormInput()

Returns this element as a FormInput

toHidden

Source

Hidden toHidden()

Returns this element as a Hidden input

Source

Link toLink()

Returns this element as a Link

toOption

Source

Option toOption()

Returns this element as an Option

toRadioButton

Source

RadioButton toRadioButton()

Returns this element as a RadioButton input.

toSelectBox

Source

SelectBox toSelectBox()

Returns this element as a SelectBox

toStr

Source

virtual override Str toStr()

Returns the complete CSS selector and the resulting HTML.

toSubmitButton

Source

SubmitButton toSubmitButton()

Returns this element as a SubmitButton

toTextBox

Source

TextBox toTextBox()

Returns this element as a TextBox

verifyAttrEq

Source

Void verifyAttrEq(Str attrName, Obj expected)

Verify that the element has the given attribute value.

verifyAttrExists

Source

Void verifyAttrExists(Str attrName)

Verify that the element defines the given attribute, regardless of value.

verifyCssClassContains

Source

Void verifyCssClassContains(Obj expected)

Verify that the current selection has the given size.

verifyDoesNotExist

Source

Void verifyDoesNotExist()

Verify that the current selection heralds no elements, otherwise throw a test failure exception.

verifyExists

Source

Void verifyExists()

Verify that at least one element is selected from the document, otherwise throw a test failure exception.

verifySizeEq

Source

Void verifySizeEq(Int expectedSize)

Verify that the current selection has the given size.

verifyTextContains

Source

Void verifyTextContains(Obj contains)

Verify that the element text contains the given str. The match is case insensitive.

verifyTextEq

Source

Void verifyTextEq(Obj expected)

Verify that the given text matches the text of the element. The match is case insensitive.

xelem

Source

XElem? xelem(Bool checked := true)

Returns the first XElem object.

Returns null if checked is false and no elements are found. Always throws an Err is multiple elements are returned.

xelems

Source

XElem[] xelems()

Returns a list of underlying XElem objects. The list may be empty.