Skip to main content

Class: SelectDriver

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:103

Driver for a Radix Select (Select.Root/Select.Trigger from radix-ui) — the flagship pain point of this wave.

The hasPointerCapture jsdom gap (this documentation IS the fix's value proposition, per #1003): Select.Trigger's onPointerDown handler unconditionally calls target.hasPointerCapture(event.pointerId) before opening (to release a stray capture Radix itself may have set — see @radix-ui/react-select's SelectTrigger). jsdom does not implement the Pointer Events capture methods at all (Element.prototype.hasPointerCapture is simply absent — https://github.com/jsdom/jsdom/issues/2527), so the very first click on ANY Radix Select throws target.hasPointerCapture is not a function under jsdom and the dropdown never opens — a harder failure than the "opens then immediately closes" framing suggests; nothing opens at all. A second, independent jsdom gap (scrollIntoView, called by Select.ItemText to keep the highlighted item in view on open) throws the same way immediately after. The fix is a jsdom-only polyfill, not a driver-level workaround: package-tests/component-driver-radix-test/jest.setup.ts stubs hasPointerCapture/setPointerCapture/releasePointerCapture (return false/no-op, matching jsdom's real "never actually captures a pointer" behavior) and scrollIntoView (no-op; jsdom has no layout to scroll). Real browsers implement the full Pointer Events + scroll APIs natively — this gap and its fix are jsdom-only, verified against the chromium E2E run.

No data-value on Select.Item (the #923 decision, already recorded in agent-docs/modules/component-driver-radix.md): unlike MUI, Radix does not render the value prop as a DOM attribute anywhere — the only portably readable identity for an item is its VISIBLE LABEL. getValue/setValue therefore operate on that label (not an underlying value, unlike MUI's data-value-backed SelectDriver); getSelectedLabel/selectByLabel are the primary, unambiguously-named surface, mirroring how #923 already commits every Radix driver in this epic to getText-based item matching instead of accname/value resolution.

Reading the selected label excludes the icon: Select.Icon with no children (this driver's test scene, and Radix's own docs example) renders a default "▼" glyph as a <span aria-hidden="true">, a sibling of Select.Value's span inside the trigger — both are plain <span>s with no other distinguishing attribute. A whole-trigger getText() would therefore read "Apple▼". getSelectedLabel instead reads only the trigger's direct child span that is NOT aria-hidden, mirroring what real accessible-name computation does (skip aria-hidden branches) without needing the accname-aware findByRole #923 deferred.

Extends​

  • ComponentDriver<typeof selectParts>

Implements​

  • IInputDriver<string | null>

Constructors​

Constructor​

new SelectDriver(locator, interactor, option?): SelectDriver

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:104

Parameters​

locator​

PartLocator

interactor​

Interactor

option?​

Partial<IComponentDriverOption<{ }>>

Returns​

SelectDriver

Overrides​

ComponentDriver<typeof selectParts>.constructor

Accessors​

driverName​

Get Signature​

get driverName(): string

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:242

Returns​

string

Overrides​

ComponentDriver.driverName

Methods​

closeDropdown()​

closeDropdown(): Promise<void>

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:125

Close the dropdown by clicking the trigger, if open.

Returns​

Promise<void>


getMenuItemByIndex()​

getMenuItemByIndex(index): Promise<MenuItemDriver | null>

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:208

The option at the given zero-based index, or null if out of range.

Parameters​

index​

number

Returns​

Promise<MenuItemDriver | null>


getMenuItemByLabel()​

getMenuItemByLabel(label, option?): Promise<MenuItemDriver | null>

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:164

The item whose visible label matches label, or null when absent. Opens the dropdown first unless option.skipDropdownCheck is set.

Parameters​

label​

string

option?​

SelectItemGetOption

Returns​

Promise<MenuItemDriver | null>


getMenuItemCount()​

getMenuItemCount(): Promise<number>

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:202

The number of options in the open dropdown.

Returns​

Promise<number>


getSelectedLabel()​

getSelectedLabel(): Promise<string | null>

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:133

The trigger's visible selected-value text, excluding the decorative icon (see class doc).

Returns​

Promise<string | null>


getValue()​

getValue(): Promise<string | null>

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:140

Alias for getSelectedLabel — satisfies IInputDriver. See class doc for why "value" is the label here.

Returns​

Promise<string | null>

Implementation of​

IInputDriver.getValue


isDisabled()​

isDisabled(): Promise<boolean>

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:233

Whether the trigger is disabled — Radix mirrors this as aria-disabled/data-disabled.

Returns​

Promise<boolean>


isDropdownOpen()​

isDropdownOpen(): Promise<boolean>

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:112

Whether the dropdown is open — read from the trigger's Radix data-state.

Returns​

Promise<boolean>


isRequired()​

isRequired(): Promise<boolean>

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:238

Whether the trigger is marked required (aria-required, set when Select.Root's required prop is true).

Returns​

Promise<boolean>


openDropdown()​

openDropdown(): Promise<void>

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:117

Open the dropdown by clicking the trigger, if not already open.

Returns​

Promise<void>


selectByLabel()​

selectByLabel(label): Promise<void>

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:191

Click the item whose visible label matches label.

Parameters​

label​

string

Returns​

Promise<void>

Throws​

when absent.


setValue()​

setValue(value): Promise<boolean>

Defined in: packages/component-driver-radix-v1/src/components/SelectDriver.ts:148

Select the item whose visible label matches value, if it exists.

Parameters​

value​

string | null

Returns​

Promise<boolean>

false when no such item exists (does not throw — see selectByLabel for the throwing variant).

Implementation of​

IInputDriver.setValue

Inherited members (20)

Properties​

commutableOption​

readonly commutableOption: CommutableComponentDriverOption

Defined in: packages/core/dist/index.d.mts:1182

The component-agnostic slice of the constructor option that is safe to share across the whole driver tree — everything the constructor received EXCEPT the component-specific parts, which each driver owns for itself. Parent drivers pass this straight to the constructors of children they create dynamically (see the list helpers). See CommutableComponentDriverOption.

Inherited from​

ComponentDriver.commutableOption


interactor​

readonly interactor: Interactor

Defined in: packages/core/dist/index.d.mts:1172

Inherited from​

ComponentDriver.interactor

Accessors​

locator​

Get Signature​

get locator(): PartLocator

Defined in: packages/core/dist/index.d.mts:1229

Return the locator of the component

Returns​

PartLocator

Inherited from​

ComponentDriver.locator


parts​

Get Signature​

get parts(): ScenePartDriver<T>

Defined in: packages/core/dist/index.d.mts:1225

Return driver instance of all the named parts

Returns​

ScenePartDriver<T>

Inherited from​

ComponentDriver.parts

Methods​

click()​

click(option?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1253

Parameters​
option?​

Partial<ClickOption>

Returns​

Promise<void>

Inherited from​

ComponentDriver.click


exists()​

exists(): Promise<boolean>

Defined in: packages/core/dist/index.d.mts:1252

Whether the component exists/attached to the DOM

Returns​

Promise<boolean>

true if the component is attached to the DOM, false otherwise

Inherited from​

ComponentDriver.exists


focus()​

focus(option?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1262

Parameters​
option?​

Partial<FocusOption>

Returns​

Promise<void>

Inherited from​

ComponentDriver.focus


getAttribute()​

getAttribute(attributeName): Promise<Optional<string>>

Defined in: packages/core/dist/index.d.mts:1247

Parameters​
attributeName​

string

Returns​

Promise<Optional<string>>

Inherited from​

ComponentDriver.getAttribute


getText()​

getText(): Promise<Optional<string>>

Defined in: packages/core/dist/index.d.mts:1246

Get the combined text content of the component

Returns​

Promise<Optional<string>>

If the component exists and has content, it should return the text or otherwise undefined

Inherited from​

ComponentDriver.getText


hover()​

hover(option?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1254

Parameters​
option?​

Partial<HoverOption>

Returns​

Promise<void>

Inherited from​

ComponentDriver.hover


isVisible()​

isVisible(): Promise<boolean>

Defined in: packages/core/dist/index.d.mts:1336

Whether the component is visible. Visibility is defined that the component does not have the CSS property display: none, visibility: hidden, or opacity: 0. However this does not check whether the component is within the viewport.

Returns​

Promise<boolean>

true if the component is visible, false otherwise

Inherited from​

ComponentDriver.isVisible


pressKey()​

pressKey(key, option?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1268

Dispatch a keyboard key press on the component. See Interactor.pressKey.

Parameters​
key​

string

A KeyboardEvent.key value, e.g. 'Escape', 'Backspace', 'Enter'

option?​

Partial<PressKeyOption>

Reserved for future modifier-key support

Returns​

Promise<void>

Inherited from​

ComponentDriver.pressKey


runtimeCssSelector()​

runtimeCssSelector(): Promise<string>

Defined in: packages/core/dist/index.d.mts:1367

Get the runtime CSS selector of the component. This is useful for debugging and testing purposes.

Returns​

Promise<string>

The runtime CSS selector of the component

Inherited from​

ComponentDriver.runtimeCssSelector


scrollIntoView()​

scrollIntoView(): Promise<void>

Defined in: packages/core/dist/index.d.mts:1289

Scroll the component into the viewport. See Interactor.scrollIntoView.

jsdom has no layout engine, so the scroll is a no-op there and behavioral assertions (visibility, offset) are E2E-only.

Returns​

Promise<void>

Inherited from​

ComponentDriver.scrollIntoView


typeText()​

typeText(text): Promise<void>

Defined in: packages/core/dist/index.d.mts:1274

Type text into the component as real per-character keystrokes, inserting at the current caret without clearing. See Interactor.typeText.

Parameters​
text​

string

The literal text to type, one keystroke per character

Returns​

Promise<void>

Inherited from​

ComponentDriver.typeText


waitUntil()​

waitUntil<T>(option): Promise<T>

Defined in: packages/core/dist/index.d.mts:1356

Type Parameters​
T​

T

Parameters​
option​

WaitUntilOption<T>

Returns​

Promise<T>

Inherited from​

ComponentDriver.waitUntil


waitUntilComponentState()​

waitUntilComponentState(option?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1355

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​
option?​

Partial<Readonly<WaitForOption>>

The option to configure the wait behavior

Returns​

Promise<void>

Inherited from​

ComponentDriver.waitUntilComponentState


waitUntilVisible()​

waitUntilVisible(timeoutMs?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1343

Wait until the component is attached and becomes visible to the DOM.

Parameters​
timeoutMs?​

number

The number of milliseconds to wait before timing out. Defaults to defaultWaitForOption.timeoutMs so this wait shares a single flake-tolerance source with waitUntilComponentState (#1057).

Returns​

Promise<void>

Inherited from​

ComponentDriver.waitUntilVisible


overriddenParentLocator()​

static overriddenParentLocator(): Optional<PartLocator>

Defined in: packages/core/dist/index.d.mts:1211

Portal hook: where to re-root this driver's locator when its component renders outside the parent's DOM (a modal, popup, drawer). Return the PartLocator that locates the component from the document root, or undefined (the default) for normal in-tree components whose locator chains from the parent.

This is static because it is per-class metadata read off the constructor before any instance exists — which makes the "no instance state" constraint structural rather than a documented caution. Override with static override.

Returns​

Optional<PartLocator>

Inherited from​

ComponentDriver.overriddenParentLocator


overrideLocatorRelativePosition()​

static overrideLocatorRelativePosition(): Optional<LocatorRelativePosition>

Defined in: packages/core/dist/index.d.mts:1221

Portal hook: the locator relative position to apply when the component's real DOM is a sibling/elsewhere rather than a descendant (e.g. a MUI dialog rendered at the document root, located by a "Same"-level selector). Return undefined (the default) to keep the natural position declared by the ScenePart.

Static for the same reason as ComponentDriver.overriddenParentLocator: it is class-level metadata read before construction. Override with static override.

Returns​

Optional<LocatorRelativePosition>

Inherited from​

ComponentDriver.overrideLocatorRelativePosition

Protected members (16)

Methods​

activate()​

protected activate(): Promise<void>

Defined in: packages/core/dist/index.d.mts:1282

Activate the component without relying on pointer geometry. See Interactor.activate.

Returns​

Promise<void>

Inherited from​

ComponentDriver.activate


contextMenu()​

protected contextMenu(): Promise<void>

Defined in: packages/core/dist/index.d.mts:1278

Dispatch a right-click / contextmenu event on the component. See Interactor.contextMenu.

Returns​

Promise<void>

Inherited from​

ComponentDriver.contextMenu


drag()​

protected drag(delta): Promise<void>

Defined in: packages/core/dist/index.d.mts:1320

Drag this component by the given pixel delta from its center. See Interactor.drag.

Prefer a keyboard-driven setValue over a true drag in real drivers — these drag primitives exist only for cases keyboard cannot express (e.g. panning a Lightbox, reordering a column). jsdom has no layout engine, so the positional outcome of the drag is E2E-only there.

Parameters​
delta​

Point

Pixel offset to drag by

Returns​

Promise<void>

Inherited from​

ComponentDriver.drag


dragTo()​

protected dragTo(target): Promise<void>

Defined in: packages/core/dist/index.d.mts:1309

Drag this component and drop it onto another component. See Interactor.dragTo.

Prefer a keyboard-driven setValue over a true drag in real drivers — these drag primitives exist only for cases keyboard cannot express (e.g. panning a Lightbox, reordering a column). jsdom has no layout engine, so the positional outcome of the drag is E2E-only there.

Parameters​
target​

ComponentDriver<any>

Another driver whose root element is the drop target

Returns​

Promise<void>

Inherited from​

ComponentDriver.dragTo


enforcePartExistence()​

protected enforcePartExistence(partName): Promise<void>

Defined in: packages/core/dist/index.d.mts:1235

Check the specified parts' existences, and throw MissingPartError if any of the part is found not existence. Existence is defined by the part's existence in the DOM regardless of its visibility on the screen

Parameters​
partName​

"dropdown" | readonly "dropdown"[]

Single or array of the names of the parts to be enforced

Returns​

Promise<void>

Inherited from​

ComponentDriver.enforcePartExistence


getBoundingRect()​

protected getBoundingRect(): Promise<BoundingRect>

Defined in: packages/core/dist/index.d.mts:1327

Get this component's bounding rectangle. See Interactor.getBoundingRect.

jsdom has no layout engine, so every coordinate and dimension is 0 there; real geometry is E2E-only.

Returns​

Promise<BoundingRect>

Inherited from​

ComponentDriver.getBoundingRect


getMissingPartNames()​

protected getMissingPartNames(partName): Promise<readonly "dropdown"[]>

Defined in: packages/core/dist/index.d.mts:1241

Get the names of parts not in the DOM

Parameters​
partName​

"dropdown" | readonly "dropdown"[]

Single or array of the names of the parts to be examined

Returns​

Promise<readonly "dropdown"[]>

Inherited from​

ComponentDriver.getMissingPartNames


innerHTML()​

protected innerHTML(): Promise<string>

Defined in: packages/core/dist/index.d.mts:1361

Get the inner HTML of the component

Returns​

Promise<string>

The inner HTML of the component

Inherited from​

ComponentDriver.innerHTML


mouseDown()​

protected mouseDown(option?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1256

Parameters​
option?​

Partial<MouseDownOption>

Returns​

Promise<void>

Inherited from​

ComponentDriver.mouseDown


mouseEnter()​

protected mouseEnter(option?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1260

Parameters​
option?​

Partial<MouseEnterOption>

Returns​

Promise<void>

Inherited from​

ComponentDriver.mouseEnter


mouseLeave()​

protected mouseLeave(option?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1261

Parameters​
option?​

Partial<MouseLeaveOption>

Returns​

Promise<void>

Inherited from​

ComponentDriver.mouseLeave


mouseMove()​

protected mouseMove(option?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1255

Parameters​
option?​

Partial<MouseMoveOption>

Returns​

Promise<void>

Inherited from​

ComponentDriver.mouseMove


mouseOut()​

protected mouseOut(option?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1259

Parameters​
option?​

Partial<MouseOutOption>

Returns​

Promise<void>

Inherited from​

ComponentDriver.mouseOut


mouseOver()​

protected mouseOver(option?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1258

Parameters​
option?​

Partial<HoverOption>

Returns​

Promise<void>

Inherited from​

ComponentDriver.mouseOver


mouseUp()​

protected mouseUp(option?): Promise<void>

Defined in: packages/core/dist/index.d.mts:1257

Parameters​
option?​

Partial<MouseUpOption>

Returns​

Promise<void>

Inherited from​

ComponentDriver.mouseUp


scrollBy()​

protected scrollBy(delta): Promise<void>

Defined in: packages/core/dist/index.d.mts:1298

Scroll the component by the given pixel delta. See Interactor.scrollBy.

jsdom has no layout engine, so the scroll is a no-op there and behavioral assertions (resulting offset) are E2E-only.

Parameters​
delta​

Point

Pixel offset to scroll by

Returns​

Promise<void>

Inherited from​

ComponentDriver.scrollBy