interaction module

class interaction()
interaction.clearElement(el)

Clears the form control or the editable element, if required.

Before clearing the element, it will attempt to scroll it into view if it is not already in the viewport. An error is raised if the element cannot be brought into view.

If the element is a submittable form control and it is empty (it has no value or it has no files associated with it, in the case it is a <code>&lt;input type=file&gt;</code> element) or it is an editing host and its <code>innerHTML</code> content IDL attribute is empty, this function acts as a no-op.

Arguments
  • el (Element) – Element to clear.

Throws

InvalidElementStateError – If element is disabled, read-only, non-editable, not a submittable element or not an editing host, or cannot be scrolled into view.

interaction.clickElement(el, strict=false, specCompat=false)

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 <var>specCompat</var> is false (default). Otherwise pointer-interactability checks will be performed. If either of these fail an {@link ElementNotInteractableError} is thrown.

If <var>strict</var> is enabled (defaults to disabled), further accessibility checks will be performed, and these may result in an {@link ElementNotAccessibleError} being returned.

When <var>el</var> is not enabled, an {@link InvalidElementStateError} is returned.

Arguments
  • el (DOMElement|XULElement) – Element to click.

  • strict (boolean) – strict Enforce strict accessibility tests.

  • specCompat (boolean) – specCompat Use WebDriver specification compatible interactability definition.

Throws
interaction.flushEventLoop(el)

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.

Arguments
  • el (Element) – Element that is expected to receive the click.

Returns

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

interaction.isElementDisplayed(el, strict=false)

Determine the element displayedness of an element.

Arguments
  • el (DOMElement|XULElement) – Element to determine displayedness of.

  • strict (boolean) – strict Enforce strict accessibility tests.

Returns

boolean – True if element is displayed, false otherwise.

interaction.isElementEnabled(el)

Check if element is enabled.

Arguments
  • el (DOMElement|XULElement) – Element to test if is enabled.

Returns

boolean – True if enabled, false otherwise.

interaction.isElementSelected(el, strict=false)

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

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

Arguments
  • el (DOMElement|XULElement) – Element to test if is selected.

  • strict (boolean) – strict Enforce strict accessibility tests.

Throws

ElementNotAccessibleError – If <var>el</var> is not accessible when <var>strict</var> is true.

Returns

boolean – True if element is selected, false otherwise.

interaction.isKeyboardInteractable(el)

Performs checks if <var>el</var> 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.

Arguments
  • el (Element) – Element to check.

Returns

boolean – True if element is keyboard-interactable, false otherwise.

interaction.moveCaretToEnd(el)

If <var>el<var> is a textual form control and no previous selection state exists, move the caret to the end of the form control.

The element has to be a <code>&lt;input type=text&gt;</code> or <code>&lt;textarea&gt;</code> element for the cursor to move be moved.

Arguments
  • el (Element) – Element to potential move the caret in.

interaction.selectOption(option)

Select <tt>&lt;option&gt;</tt> element in a <tt>&lt;select&gt;</tt> 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.

Arguments
  • option (HTMLOptionElement) – Option element to select.

Throws
  • TypeError – If <var>el</var> is a XUL element or not an <tt>&lt;option&gt;</tt> element.

  • Error – If unable to find <var>el</var>’s parent <tt>&lt;select&gt;</tt> element.

interaction.sendKeysToElement(el, value, strictFileInteractability, accessibilityChecks, webdriverClick)

Send keys to element.

Arguments
  • el (DOMElement|XULElement) – Element to send key events to.

  • value (Array.<string>) – Sequence of keystrokes to send to the element.

  • strictFileInteractability (boolean) – Run interactability checks on <input type=file> elements.

  • accessibilityChecks (boolean) – Enforce strict accessibility tests.

  • webdriverClick (boolean) – Use WebDriver specification compatible interactability definition.

interaction.setFormControlValue(el, value)

Sets a form element’s value.

Arguments
  • el (DOMElement) – An form element, e.g. input, textarea, etc.

  • value (string) – The value to be set.

Throws

TypeError – If <var>el</var> is not an supported form element.

interaction.uploadFiles(el, paths)

Updates an <input type=file>’s file list with given paths.

Hereby will the file list be appended with paths if the element allows multiple files. Otherwise the list will be replaced.

Arguments
  • el (HTMLInputElement) – An input type=file element.

  • paths (Array.<string>) – List of full paths to any of the files to be uploaded.

Throws

InvalidArgumentError – If path doesn’t exist.