interaction module

class interaction()

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.

  • el (Element()) – Element to clear.


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.

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

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

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

  • ElementNotInteractableError() – If either Selenium-style visibility check or pointer-interactability check fails.

  • ElementClickInterceptedError() – If <var>el</var> is obscured by another element and a click would not hit, in <var>specCompat</var> mode.

  • ElementNotAccessibleError() – If <var>strict</var> is true and element is not accessible.

  • InvalidElementStateError() – If <var>el</var> is not enabled.


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.

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


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.

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

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


boolean – True if element is displayed, false otherwise.


Check if element is enabled.

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


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.

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

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


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


boolean – True if element is selected, false otherwise.


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.

  • el (Element()) – Element to check.


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


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.

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


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.

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

  • 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.

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

  • value (Array.) – 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.

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

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


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.

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

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


InvalidArgumentError() – If path doesn’t exist.