Class: DOMInteractor
Defined in: packages/dom-core/src/DOMInteractor.ts:85
Implements​
Interactor
Constructors​
Constructor​
new DOMInteractor(
rootEl?,option?):DOMInteractor
Defined in: packages/dom-core/src/DOMInteractor.ts:88
Parameters​
rootEl?​
HTMLElement = document.documentElement
option?​
Returns​
DOMInteractor
Methods​
activate()​
activate(
locator):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:567
Activate the element matched by the locator without pointer geometry.
Uses userEvent.click, which ignores layout and coordinates, so it reaches a
visually-hidden or covered input that a positional click would miss (e.g. MUI
Rating's hidden <input type="radio">).
Parameters​
locator​
PartLocator
Locator used to find the target element
Returns​
Promise<void>
Promise resolved once the element has been activated
Throws​
If the element is not found
Implementation of​
Interactor.activate
blur()​
blur(
locator,_option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:395
Remove focus from the element found by the locator.
Parameters​
locator​
PartLocator
Locator used to find the target element
_option?​
Partial<BlurOption>
Reserved for future use
Returns​
Promise<void>
Promise resolved when blur has been applied
Throws​
If the element is not found
Implementation of​
Interactor.blur
click()​
click(
locator,option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:161
Dispatch a click event on the element that matches the locator.
Parameters​
locator​
PartLocator
Locator used to find the target element
option?​
ClickOption
Optional click configuration such as the click position
Returns​
Promise<void>
A promise that resolves after the event is triggered
Throws​
If the element is not found
Implementation of​
Interactor.click
contextMenu()​
contextMenu(
locator):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:543
Dispatch a contextmenu (right-click) event on the element matched by the locator.
The element is focused first if focusable, mirroring pressKey, so the
event originates from the active element as a real right-click would. A
context menu has no aria-expanded/controlled-open path, so this dispatched
event is the only way to exercise the menu-opening behavior.
Parameters​
locator​
PartLocator
Locator used to find the target element
Returns​
Promise<void>
Promise resolved once the event has been dispatched
Throws​
If the element is not found
Implementation of​
Interactor.contextMenu
drag()​
drag(
locator,delta):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:853
Drag the located element by the given pixel delta from its center.
The sequence (mousedown at center → mousemove at center + delta →
mouseup at center + delta) is synthesized with the shared
dispatchMouse + calculateMousePosition pattern, using the
caller-supplied delta for the move/up coordinates. jsdom has no layout, so the
center resolves to zeros and only the event wiring is exercised — the
behavioral outcome of the drag is E2E-only.
Only raw mouse events are fired; native HTML5 drag-and-drop is NOT synthesized — see #922.
Parameters​
locator​
PartLocator
Locator used to find the element to drag
delta​
Point
Pixel offset to drag by
Returns​
Promise<void>
Throws​
If the element is not found
Implementation of​
Interactor.drag
dragTo()​
dragTo(
source,target):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:816
Drag the source element and drop it onto the target element.
The pointer sequence (mousedown on source → mousemove on target →
mouseup on target) is synthesized with the shared dispatchMouse +
calculateMousePosition pattern. jsdom has no layout, so those
coordinates are all zeros — the event wiring (and any drop handler the
sequence triggers) is exercised, but the positional outcome is E2E-only.
Only raw mouse events are fired; native HTML5 drag-and-drop
(dragstart/dragover/drop + dataTransfer) is NOT synthesized, so
components built on the HTML5 DnD API are not driven by this — see #922.
Parameters​
source​
PartLocator
Locator used to find the element to drag
target​
PartLocator
Locator used to find the drop target
Returns​
Promise<void>
Throws​
If either element is not found
Implementation of​
Interactor.dragTo
enterText()​
enterText(
locator,text,option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:586
Type text into the element matched by the locator.
Parameters​
locator​
PartLocator
Locator used to find the target element
text​
string
The string to type
option?​
Partial<EnterTextOption>
Options such as appending or replacing existing value
Returns​
Promise<void>
Promise resolved when typing has completed
Throws​
If the element is not found
Implementation of​
Interactor.enterText
exists()​
exists(
locator):Promise<boolean>
Defined in: packages/dom-core/src/DOMInteractor.ts:884
Parameters​
locator​
PartLocator
Returns​
Promise<boolean>
Implementation of​
Interactor.exists
focus()​
focus(
locator,_option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:374
Move focus to the element found by the locator.
Parameters​
locator​
PartLocator
Locator used to find the target element
_option?​
Partial<FocusOption>
Reserved for future use
Returns​
Promise<void>
Promise resolved when focus has been applied
Throws​
If the element is not found
Implementation of​
Interactor.focus
getAttribute()​
Call Signature​
getAttribute(
locator,name,isMultiple):Promise<readonlystring[]>
Defined in: packages/dom-core/src/DOMInteractor.ts:114
Parameters​
locator​
PartLocator
name​
string
isMultiple​
true
Returns​
Promise<readonly string[]>
Implementation of​
Interactor.getAttribute
Call Signature​
getAttribute(
locator,name,isMultiple):Promise<Optional<string>>
Defined in: packages/dom-core/src/DOMInteractor.ts:115
Parameters​
locator​
PartLocator
name​
string
isMultiple​
false
Returns​
Promise<Optional<string>>
Implementation of​
Interactor.getAttribute
Call Signature​
getAttribute(
locator,name):Promise<Optional<string>>
Defined in: packages/dom-core/src/DOMInteractor.ts:116
Parameters​
locator​
PartLocator
name​
string
Returns​
Promise<Optional<string>>
Implementation of​
Interactor.getAttribute
getBoundingRect()​
getBoundingRect(
locator):Promise<BoundingRect>
Defined in: packages/dom-core/src/DOMInteractor.ts:991
Get the located element's bounding rectangle.
jsdom has no layout engine, so getBoundingClientRect returns all zeros: the
rect is structurally valid but behaviorally meaningless. Real geometry is
E2E-only.
Parameters​
locator​
PartLocator
Locator used to find the element to measure
Returns​
Promise<BoundingRect>
The element's bounding rectangle (a zero-rect under jsdom)
Throws​
If the element is not found
Implementation of​
Interactor.getBoundingRect
getElement()​
Call Signature​
getElement<
T>(locator,isMultiple):Promise<readonlyT[]>
Defined in: packages/dom-core/src/DOMInteractor.ts:900
Type Parameters​
T​
T extends Element = Element
Parameters​
locator​
PartLocator
isMultiple​
true
Returns​
Promise<readonly T[]>
Call Signature​
getElement<
T>(locator,isMultiple):Promise<Optional<T>>
Defined in: packages/dom-core/src/DOMInteractor.ts:901
Type Parameters​
T​
T extends Element = Element
Parameters​
locator​
PartLocator
isMultiple​
false
Returns​
Promise<Optional<T>>
Call Signature​
getElement<
T>(locator):Promise<Optional<T>>
Defined in: packages/dom-core/src/DOMInteractor.ts:902
Type Parameters​
T​
T extends Element = Element
Parameters​
locator​
PartLocator
Returns​
Promise<Optional<T>>
getElementCount()​
getElementCount(
locator):Promise<number>
Defined in: packages/dom-core/src/DOMInteractor.ts:895
Count every element matching the locator — the length of the multi-match
query. Reuses the getElement multiple-overload rather than a second
querySelectorAll path, so the document-root (:root) escape is honored in
exactly one place. A read: it does NOT route through runInteraction.
Parameters​
locator​
PartLocator
Returns​
Promise<number>
Implementation of​
Interactor.getElementCount
getInputValue()​
getInputValue(
locator):Promise<Optional<string>>
Defined in: packages/dom-core/src/DOMInteractor.ts:940
Parameters​
locator​
PartLocator
Returns​
Promise<Optional<string>>
Implementation of​
Interactor.getInputValue
getSelectLabels()​
getSelectLabels(
locator):Promise<Optional<readonlystring[]>>
Defined in: packages/dom-core/src/DOMInteractor.ts:962
Get the select element's selected options' labels
Parameters​
locator​
PartLocator
Returns​
Promise<Optional<readonly string[]>>
Implementation of​
Interactor.getSelectLabels
getSelectValues()​
getSelectValues(
locator):Promise<Optional<readonlystring[]>>
Defined in: packages/dom-core/src/DOMInteractor.ts:952
Get the select element's selected options' values
Parameters​
locator​
PartLocator
Returns​
Promise<Optional<readonly string[]>>
Implementation of​
Interactor.getSelectValues
getStyleValue()​
getStyleValue(
locator,propertyName):Promise<Optional<string>>
Defined in: packages/dom-core/src/DOMInteractor.ts:134
Get the value of a style property
Parameters​
locator​
PartLocator
propertyName​
CssProperty
Returns​
Promise<Optional<string>>
Implementation of​
Interactor.getStyleValue
getText()​
getText(
locator):Promise<Optional<string>>
Defined in: packages/dom-core/src/DOMInteractor.ts:972
Parameters​
locator​
PartLocator
Returns​
Promise<Optional<string>>
Implementation of​
Interactor.getText
hasAttribute()​
hasAttribute(
locator,name):Promise<boolean>
Defined in: packages/dom-core/src/DOMInteractor.ts:1067
Parameters​
locator​
PartLocator
name​
string
Returns​
Promise<boolean>
Implementation of​
Interactor.hasAttribute
hasCssClass()​
hasCssClass(
locator,className):Promise<boolean>
Defined in: packages/dom-core/src/DOMInteractor.ts:1059
Parameters​
locator​
PartLocator
className​
string
Returns​
Promise<boolean>
Implementation of​
Interactor.hasCssClass
hover()​
hover(
locator,_option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:193
Move the mouse over the element.
Parameters​
locator​
PartLocator
Locator used to find the target element
_option?​
HoverOption
Reserved for future use
Returns​
Promise<void>
A promise that resolves after the hover event
Throws​
If the element is not found
Implementation of​
Interactor.hover
innerHTML()​
innerHTML(
locator):Promise<string>
Defined in: packages/dom-core/src/DOMInteractor.ts:1076
Get the HTML of an element
Parameters​
locator​
PartLocator
Returns​
Promise<string>
Implementation of​
Interactor.innerHTML
isChecked()​
isChecked(
locator):Promise<boolean>
Defined in: packages/dom-core/src/DOMInteractor.ts:1000
Parameters​
locator​
PartLocator
Returns​
Promise<boolean>
Implementation of​
Interactor.isChecked
isDisabled()​
isDisabled(
locator):Promise<boolean>
Defined in: packages/dom-core/src/DOMInteractor.ts:1008
Parameters​
locator​
PartLocator
Returns​
Promise<boolean>
Implementation of​
Interactor.isDisabled
isError()​
isError(
locator):Promise<boolean>
Defined in: packages/dom-core/src/DOMInteractor.ts:1042
Whether the element is in an invalid/error state, signalled by
aria-invalid="true" (the cross-widget convention; native validity state is
not consulted).
Parameters​
locator​
PartLocator
Returns​
Promise<boolean>
Implementation of​
Interactor.isError
isReadonly()​
isReadonly(
locator):Promise<boolean>
Defined in: packages/dom-core/src/DOMInteractor.ts:1019
Parameters​
locator​
PartLocator
Returns​
Promise<boolean>
Implementation of​
Interactor.isReadonly
isRequired()​
isRequired(
locator):Promise<boolean>
Defined in: packages/dom-core/src/DOMInteractor.ts:1031
Whether the element is marked required, via the native required property or
an aria-required="true" attribute.
Parameters​
locator​
PartLocator
Returns​
Promise<boolean>
Implementation of​
Interactor.isRequired
isVisible()​
isVisible(
locator):Promise<boolean>
Defined in: packages/dom-core/src/DOMInteractor.ts:1047
Parameters​
locator​
PartLocator
Returns​
Promise<boolean>
Implementation of​
Interactor.isVisible
mouseDown()​
mouseDown(
locator,option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:237
Dispatch a mousedown event on the target element.
Parameters​
locator​
PartLocator
Locator used to find the target element
option?​
Partial<MouseDownOption>
Allows specifying the mouse position relative to the element
Returns​
Promise<void>
Promise resolved when the event is dispatched
Throws​
If the element is not found
Implementation of​
Interactor.mouseDown
mouseEnter()​
mouseEnter(
locator,_option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:334
Dispatch a mouseenter event on the target element.
Parameters​
locator​
PartLocator
Locator used to find the target element
_option?​
Partial<MouseEnterOption>
Reserved for future use
Returns​
Promise<void>
Promise resolved after the event dispatches
Throws​
If the element is not found
Implementation of​
Interactor.mouseEnter
mouseLeave()​
mouseLeave(
locator,_option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:355
Dispatch a mouseleave event on the target element.
Parameters​
locator​
PartLocator
Locator used to find the target element
_option?​
Partial<MouseLeaveOption>
Reserved for future use
Returns​
Promise<void>
Promise resolved once the event is dispatched
Throws​
If the element is not found
Implementation of​
Interactor.mouseLeave
mouseMove()​
mouseMove(
locator,option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:211
Dispatch a mousemove event on the target element.
Parameters​
locator​
PartLocator
Locator used to find the target element
option?​
Partial<MouseMoveOption>
Allows specifying the mouse position relative to the element
Returns​
Promise<void>
A promise that resolves once the event has been dispatched
Throws​
If the element is not found
Implementation of​
Interactor.mouseMove
mouseOut()​
mouseOut(
locator,_option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:315
Dispatch a mouseout event on the target element.
Parameters​
locator​
PartLocator
Locator used to find the target element
_option?​
Partial<MouseOutOption>
Reserved for future use
Returns​
Promise<void>
Promise resolved once the event is dispatched
Throws​
If the element is not found
Implementation of​
Interactor.mouseOut
mouseOver()​
mouseOver(
locator,option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:289
Dispatch a mouseover event on the target element.
Parameters​
locator​
PartLocator
Locator used to find the target element
option?​
Partial<HoverOption>
Optional mouse position relative to the element
Returns​
Promise<void>
Promise resolved once the event is dispatched
Throws​
If the element is not found
Implementation of​
Interactor.mouseOver
mouseUp()​
mouseUp(
locator,option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:263
Dispatch a mouseup event on the target element.
Parameters​
locator​
PartLocator
Locator used to find the target element
option?​
Partial<MouseUpOption>
Allows specifying the mouse position relative to the element
Returns​
Promise<void>
Promise resolved when the event is dispatched
Throws​
If the element is not found
Implementation of​
Interactor.mouseUp
pressKey()​
pressKey(
locator,key,option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:460
Dispatch a key press (keydown + keyup) on the element matched by the locator.
The element is focused first so the key originates from the active element,
matching a real key press. fireEvent is used over userEvent.keyboard for
determinism and because MUI handlers read event.key directly. The physical
code is derived from key (see deriveKeyCode) so handlers that
switch on event.code — e.g. PrimeVue's Slider — behave as they do under a
real browser event, where code is always populated.
Parameters​
locator​
PartLocator
Locator used to find the target element
key​
string
A KeyboardEvent.key value, e.g. 'Escape', 'Backspace'
option?​
Partial<PressKeyOption>
Modifier flags folded into the event init as
ctrlKey/shiftKey/altKey/metaKey, so a handler reading
event.ctrlKey (etc.) sees the chord — see PressKeyOption
Returns​
Promise<void>
Promise resolved once the events have been dispatched
Throws​
If the element is not found
Implementation of​
Interactor.pressKey
scrollBy()​
scrollBy(
locator,delta):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:778
Scroll the located element by the given pixel delta.
jsdom has no layout engine, so the scroll offset never changes — this is a
no-op behaviorally. As with scrollIntoView, jsdom may not implement
Element.prototype.scrollBy as a function, so the typeof guard prevents a
TypeError and keeps the call a safe no-op that resolves; real scroll
behavior is E2E-only.
Parameters​
locator​
PartLocator
Locator used to find the scrollable element
delta​
Point
Pixel offset to scroll by
Returns​
Promise<void>
Throws​
If the element is not found
Implementation of​
Interactor.scrollBy
scrollIntoView()​
scrollIntoView(
locator):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:753
Scroll the located element into view.
jsdom has no layout engine, so this never produces an observable scroll —
geometry stays zeroed and nothing becomes "visible". Worse, jsdom does not
implement Element.prototype.scrollIntoView as a function in every version,
so calling it unguarded would throw a TypeError. The typeof guard keeps
this a safe no-op that resolves; real scrolling behavior is E2E-only.
Parameters​
locator​
PartLocator
Locator used to find the element
Returns​
Promise<void>
Throws​
If the element is not found
Implementation of​
Interactor.scrollIntoView
selectOptionValue()​
selectOptionValue(
locator,values):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:697
Select one or more option values in a <select> element.
Parameters​
locator​
PartLocator
Locator used to find the select element
values​
string[]
Values of the options to select
Returns​
Promise<void>
Promise resolved when the options have been selected
Throws​
If the element is not found
Implementation of​
Interactor.selectOptionValue
setInputFiles()​
setInputFiles(
locator,files):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:723
Set the selected files on an <input type="file"> element.
The interactor contract passes filesystem paths, but a file input's value
cannot be assigned programmatically — the browser blocks it — so the
FileList must be populated through userEvent.upload, which also fires the
change event. jsdom has no filesystem and never reads file bytes; only
File.name is observable, so each path is wrapped in an empty File named
by its basename. The real bytes matter only to the Playwright layer, which
reads the paths natively — keeping dom-core free of any node dependency.
Parameters​
locator​
PartLocator
Locator used to find the file input element
files​
string | string[]
One or more filesystem paths to upload
Returns​
Promise<void>
Promise resolved once the upload change event has fired
Throws​
If the element is not found
Implementation of​
Interactor.setInputFiles
setRangeValue()​
setRangeValue(
locator,value):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:679
Set the value of a range input and fire its change event.
fireEvent.change assigns the value through the element's native value
setter (which both sanitizes it to the input's step and lets React's value
tracker observe the change) and dispatches the event so a controlled
component re-renders. Typing (enterText) does not apply to a range input.
Parameters​
locator​
PartLocator
Locator used to find the range input element
value​
number
The numeric value to set
Returns​
Promise<void>
Promise resolved once the change event has fired
Throws​
If the element is not found
Implementation of​
Interactor.setRangeValue
typeText()​
typeText(
locator,text):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:632
Type text into the element as real per-character keystrokes.
Focuses the element, then dispatches the characters through
userEvent.keyboard, which fires the full key event sequence
(keydown → beforeinput → input → keyup) against the active element —
matching PlaywrightInteractor's pressSequentially (focus + keys, no
pointer event, no clearing). {/[ are doubled so user-event's
descriptor syntax never engages and the text is typed literally.
Parameters​
locator​
PartLocator
Locator used to find the target element
text​
string
The literal text to type, one keystroke per character
Returns​
Promise<void>
Promise resolved once every keystroke has been dispatched
Throws​
If the element is not found
Implementation of​
Interactor.typeText
waitUntil()​
waitUntil<
T>(option):Promise<T>
Defined in: packages/dom-core/src/DOMInteractor.ts:879
Keep running a probe function until it returns a value that matches the terminate condition or timeout
Type Parameters​
T​
T
Parameters​
option​
WaitUntilOption<T>
Returns​
Promise<T>
The last value returned by the probe function
Implementation of​
Interactor.waitUntil
waitUntilComponentState()​
waitUntilComponentState(
locator,option?):Promise<void>
Defined in: packages/dom-core/src/DOMInteractor.ts:870
Wait until the component is in the expected state such as the component's visibility or existence. If the component has not reached the expected state within the timeout, it will throw an error.
By default it waits until the component is attached to the DOM within 30 seconds.
Parameters​
locator​
PartLocator
The locator of the component to wait for
option?​
Partial<Readonly<WaitForOption>> = defaultWaitForOption
The option to configure the wait behavior
Returns​
Promise<void>
Implementation of​
Interactor.waitUntilComponentState
Protected members (4)
Properties​
rootEl​
protectedreadonlyrootEl:HTMLElement=document.documentElement
Defined in: packages/dom-core/src/DOMInteractor.ts:89
userEvent​
protectedreadonlyuserEvent:UserEventDispatcher
Defined in: packages/dom-core/src/DOMInteractor.ts:86
Methods​
calculateMousePosition()​
protectedcalculateMousePosition(el,preferredPoint?):Point
Defined in: packages/dom-core/src/DOMInteractor.ts:144
Parameters​
el​
Element
preferredPoint?​
Point
Returns​
Point
runInteraction()​
protectedrunInteraction<T>(fn):Promise<T>
Defined in: packages/dom-core/src/DOMInteractor.ts:110
Template-method seam every mutating primitive (and both wait conditions)
routes through. The base runs the interaction verbatim; framework adapters
override it to flush their reactivity around the whole interaction —
ReactInteractor wraps it in act(...), VueInteractor awaits
nextTick(). Because every mutation funnels through this one method, a new
mutating primitive added to this base is flushed by every adapter
automatically — closing the silent gap that the previous per-method
overrides left open, where an un-mirrored primitive was inherited unwrapped
(#1052).
Reads (getText, getAttribute, exists, …) deliberately do NOT route
through here: they observe state without mutating it, so there is nothing to
flush.
Type Parameters​
T​
T
Parameters​
fn​
() => Promise<T>
Returns​
Promise<T>