Namespace: interaction

interaction

Methods

(static) clickElement(el, strictopt, specCompatopt)

Interact with an element by clicking it.

The element is scrolled into view before visibility- or interactability checks are performed.

Selenium-style visibility checks will be performed if specCompat is false (default). Otherwise pointer-interactability checks will be performed. If either of these fail an ElementNotInteractableError is thrown.

If strict is enabled (defaults to disabled), further accessibility checks will be performed, and these may result in an ElementNotAccessibleError being returned.

When el is not enabled, an InvalidElementStateError is returned.

Parameters:
Name Type Attributes Default Description
el DOMElement | XULElement

Element to click.

strict boolean <optional>
false

strict Enforce strict accessibility tests.

specCompat boolean <optional>
false

specCompat Use WebDriver specification compatible interactability definition.

Source:
Throws:

(static) flushEventLoop(el) → {Promise}

Waits until the event loop has spun enough times to process the DOM events generated by clicking an element, or until the document is unloaded.

Parameters:
Name Type Description
el Element

Element that is expected to receive the click.

Source:
Returns:

Promise is resolved once el has been clicked (its click event fires), the document is unloaded, or a 500 ms timeout is reached.

Type
Promise

(static) focusElement(element)

Focus element and, if a textual input field and no previous selection state exists, move the caret to the end of the input field.

Parameters:
Name Type Description
element Element

Element to focus.

Source:

(static) isElementDisplayed(el, strictopt) → {boolean}

Determine the element displayedness of an element.

Parameters:
Name Type Attributes Default Description
el DOMElement | XULElement

Element to determine displayedness of.

strict boolean <optional>
false

strict Enforce strict accessibility tests.

Source:
Returns:

True if element is displayed, false otherwise.

Type
boolean

(static) isElementEnabled(el) → {boolean}

Check if element is enabled.

Parameters:
Name Type Description
el DOMElement | XULElement

Element to test if is enabled.

Source:
Returns:

True if enabled, false otherwise.

Type
boolean

(static) isElementSelected(el, strictopt) → {boolean}

Determines if the referenced element is selected or not, with an additional accessibility check if strict is true.

This operation only makes sense on input elements of the checkbox- and radio button states, and option elements.

Parameters:
Name Type Attributes Default Description
el DOMElement | XULElement

Element to test if is selected.

strict boolean <optional>
false

strict Enforce strict accessibility tests.

Source:
Throws:

If el is not accessible when strict is true.

Type
ElementNotAccessibleError
Returns:

True if element is selected, false otherwise.

Type
boolean

(static) isKeyboardInteractable(el) → {boolean}

Performs checks if el is keyboard-interactable.

To decide if an element is keyboard-interactable various properties, and computed CSS styles have to be evaluated. Whereby it has to be taken into account that the element can be part of a container (eg. option), and as such the container has to be checked instead.

Parameters:
Name Type Description
el Element

Element to check.

Source:
Returns:

True if element is keyboard-interactable, false otherwise.

Type
boolean

(static) selectOption(option)

Select <option> element in a <select> list.

Because the dropdown list of select elements are implemented using native widget technology, our trusted synthesised events are not able to reach them. Dropdowns are instead handled mimicking DOM events, which for obvious reasons is not ideal, but at the current point in time considered to be good enough.

Parameters:
Name Type Description
option HTMLOptionElement

Option element to select.

Source:
Throws:
  • If el is a XUL element or not an <option> element.

    Type
    TypeError
  • If unable to find el's parent <select> element.

    Type
    Error

(static) sendKeysToElement(el, value, strictopt, specCompatopt)

Send keys to element.

Parameters:
Name Type Attributes Default Description
el DOMElement | XULElement

Element to send key events to.

value Array.<string>

Sequence of keystrokes to send to the element.

strict boolean <optional>
false

strict Enforce strict accessibility tests.

specCompat boolean <optional>
false

specCompat Use WebDriver specification compatible interactability definition.

Source:

(static) setFormControlValue(el, value)

Sets a form element's value.

Parameters:
Name Type Description
el DOMElement

An form element, e.g. input, textarea, etc.

value string

The value to be set.

Source:
Throws:

If el is not an supported form element.

Type
TypeError

(static) uploadFile(el, path)

Appends path to an <input type=file>'s file list.

Parameters:
Name Type Description
el HTMLInputElement

An <input type=file> element.

path string

Full path to file.

Source:
Throws:

If path can not be found.

Type
InvalidArgumentError