Class: ToggleButtonDriver
Defined in: component-driver-astryx/src/components/ToggleButtonDriver.ts:13
Driver for the Astryx ToggleButton (@astryxdesign/core/ToggleButton).
ToggleButton renders a native <button> that reports its on/off state through
aria-pressed and always sets an explicit aria-label (so getLabel is
reliable even though the visible text is duplicated for width reservation).
Selection is toggled by clicking — mirrors the MUI ToggleButtonDriver.
Extends​
Implements​
IToggleDriver
Constructors​
Constructor​
new ToggleButtonDriver(
locator,interactor,option?):ToggleButtonDriver
Defined in: core/dist/index.d.mts:1200
Parameters​
locator​
PartLocator
Locator for the root of this component.
interactor​
Interactor
Environment adapter used for all interactions.
option?​
Partial<IComponentDriverOption<{ }>>
Driver option carrying the shared driver-tree context.
Composite-driver authoring rule: a driver that declares non-empty parts
must type this parameter as Partial<IComponentDriverOption> (i.e. the empty
<{}> default) and hardcode its own parts in the body —
super(locator, interactor, { ...option, parts }). The "natural"
Partial<IComponentDriverOption<typeof parts>> signature does NOT satisfy
ScenePartDefinition['driver'] (constructor parameters are checked
contravariantly), so a driver written that way could not be placed in a
parent ScenePart. Lock a composite driver against this rule in one line with
AssertScenePlaceableDriver; the rule itself is regression-tested
centrally in core/src/drivers/__type-tests__ and demonstrated in
@atomic-testing/component-driver-html.
Returns​
ToggleButtonDriver
Inherited from​
Accessors​
driverName​
Get Signature​
get driverName():
string
Defined in: component-driver-astryx/src/components/ToggleButtonDriver.ts:26
Identifier for this driver. Primarily used by debugging utilities.
Returns​
string
Overrides​
Methods​
isSelected()​
isSelected():
Promise<boolean>
Defined in: component-driver-astryx/src/components/ToggleButtonDriver.ts:15
Whether the toggle is pressed (aria-pressed="true").
Returns​
Promise<boolean>
Implementation of​
IToggleDriver.isSelected
setSelected()​
setSelected(
selected):Promise<void>
Defined in: component-driver-astryx/src/components/ToggleButtonDriver.ts:20
Click to reach selected when not already there.
Parameters​
selected​
boolean
Returns​
Promise<void>
Implementation of​
IToggleDriver.setSelected
Inherited members (23)
Properties​
commutableOption​
readonlycommutableOption:CommutableComponentDriverOption
Defined in: 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​
interactor​
readonlyinteractor:Interactor
Defined in: core/dist/index.d.mts:1172
Inherited from​
Accessors​
locator​
Get Signature​
get locator():
PartLocator
Defined in: core/dist/index.d.mts:1229
Return the locator of the component
Returns​
PartLocator
Inherited from​
parts​
Get Signature​
get parts():
ScenePartDriver<T>
Defined in: core/dist/index.d.mts:1225
Return driver instance of all the named parts
Returns​
ScenePartDriver<T>
Inherited from​
Methods​
click()​
click(
option?):Promise<void>
Defined in: core/dist/index.d.mts:1253
Parameters​
option?​
Partial<ClickOption>
Returns​
Promise<void>
Inherited from​
exists()​
exists():
Promise<boolean>
Defined in: 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​
focus()​
focus(
option?):Promise<void>
Defined in: core/dist/index.d.mts:1262
Parameters​
option?​
Partial<FocusOption>
Returns​
Promise<void>
Inherited from​
getAttribute()​
getAttribute(
attributeName):Promise<Optional<string>>
Defined in: core/dist/index.d.mts:1247
Parameters​
attributeName​
string
Returns​
Promise<Optional<string>>
Inherited from​
getLabel()​
getLabel():
Promise<Optional<string>>
Defined in: component-driver-astryx/src/components/ButtonDriver.ts:29
The button's accessible name.
Astryx shows label as visible text by default and only emits an explicit
aria-label for the icon-only / loading / children-differ-from-label
cases. This returns the verbatim aria-label when present and non-empty,
otherwise the visible text. It is a deliberate stopgap — NOT the full
accessible-name algorithm (aria-labelledby / associated <label>
resolution is the deferred name-aware findByRole, per #909/#923).
|| (not ??) is intentional: an empty aria-label ("") is not a usable
name, so it falls through to the visible text rather than being returned.
Returns​
Promise<Optional<string>>
Inherited from​
getText()​
getText():
Promise<Optional<string>>
Defined in: 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​
hover()​
hover(
option?):Promise<void>
Defined in: core/dist/index.d.mts:1254
Parameters​
option?​
Partial<HoverOption>
Returns​
Promise<void>
Inherited from​
isDisabled()​
isDisabled():
Promise<boolean>
Defined in: component-driver-astryx/src/components/ButtonDriver.ts:41
Whether the button is disabled.
Astryx disables via the native disabled attribute, except when a tooltip
is set — then it keeps the button focusable and signals state with
aria-disabled="true" instead. Treat either as disabled.
Returns​
Promise<boolean>
Inherited from​
isLoading()​
isLoading():
Promise<boolean>
Defined in: component-driver-astryx/src/components/ButtonDriver.ts:55
Whether the button is in a loading state.
Astryx keeps the button mounted while an async clickAction runs and signals
the pending state with aria-busy="true" (plus an inner live-region spinner).
Returns​
Promise<boolean>
Inherited from​
isVisible()​
isVisible():
Promise<boolean>
Defined in: 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​
pressKey()​
pressKey(
key,option?):Promise<void>
Defined in: 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​
runtimeCssSelector()​
runtimeCssSelector():
Promise<string>
Defined in: 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​
ButtonDriver.runtimeCssSelector
scrollIntoView()​
scrollIntoView():
Promise<void>
Defined in: 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​
typeText()​
typeText(
text):Promise<void>
Defined in: 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​
waitUntil()​
waitUntil<
T>(option):Promise<T>
Defined in: core/dist/index.d.mts:1356
Type Parameters​
T​
T
Parameters​
option​
WaitUntilOption<T>
Returns​
Promise<T>
Inherited from​
waitUntilComponentState()​
waitUntilComponentState(
option?):Promise<void>
Defined in: 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​
ButtonDriver.waitUntilComponentState
waitUntilVisible()​
waitUntilVisible(
timeoutMs?):Promise<void>
Defined in: 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​
overriddenParentLocator()​
staticoverriddenParentLocator():Optional<PartLocator>
Defined in: 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​
ButtonDriver.overriddenParentLocator
overrideLocatorRelativePosition()​
staticoverrideLocatorRelativePosition():Optional<LocatorRelativePosition>
Defined in: 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​
Protected members (16)
Methods​
activate()​
protectedactivate():Promise<void>
Defined in: core/dist/index.d.mts:1282
Activate the component without relying on pointer geometry. See Interactor.activate.
Returns​
Promise<void>
Inherited from​
contextMenu()​
protectedcontextMenu():Promise<void>
Defined in: core/dist/index.d.mts:1278
Dispatch a right-click / contextmenu event on the component. See Interactor.contextMenu.
Returns​
Promise<void>
Inherited from​
drag()​
protecteddrag(delta):Promise<void>
Defined in: 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​
dragTo()​
protecteddragTo(target):Promise<void>
Defined in: 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​
enforcePartExistence()​
protectedenforcePartExistence(partName):Promise<void>
Defined in: 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​
readonly never[]
Single or array of the names of the parts to be enforced
Returns​
Promise<void>
Inherited from​
ButtonDriver.enforcePartExistence
getBoundingRect()​
protectedgetBoundingRect():Promise<BoundingRect>
Defined in: 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​
getMissingPartNames()​
protectedgetMissingPartNames(partName):Promise<readonlynever[]>
Defined in: core/dist/index.d.mts:1241
Get the names of parts not in the DOM
Parameters​
partName​
readonly never[]
Single or array of the names of the parts to be examined
Returns​
Promise<readonly never[]>
Inherited from​
ButtonDriver.getMissingPartNames
innerHTML()​
protectedinnerHTML():Promise<string>
Defined in: core/dist/index.d.mts:1361
Get the inner HTML of the component
Returns​
Promise<string>
The inner HTML of the component
Inherited from​
mouseDown()​
protectedmouseDown(option?):Promise<void>
Defined in: core/dist/index.d.mts:1256
Parameters​
option?​
Partial<MouseDownOption>
Returns​
Promise<void>
Inherited from​
mouseEnter()​
protectedmouseEnter(option?):Promise<void>
Defined in: core/dist/index.d.mts:1260
Parameters​
option?​
Partial<MouseEnterOption>
Returns​
Promise<void>
Inherited from​
mouseLeave()​
protectedmouseLeave(option?):Promise<void>
Defined in: core/dist/index.d.mts:1261
Parameters​
option?​
Partial<MouseLeaveOption>
Returns​
Promise<void>
Inherited from​
mouseMove()​
protectedmouseMove(option?):Promise<void>
Defined in: core/dist/index.d.mts:1255
Parameters​
option?​
Partial<MouseMoveOption>
Returns​
Promise<void>
Inherited from​
mouseOut()​
protectedmouseOut(option?):Promise<void>
Defined in: core/dist/index.d.mts:1259
Parameters​
option?​
Partial<MouseOutOption>
Returns​
Promise<void>
Inherited from​
mouseOver()​
protectedmouseOver(option?):Promise<void>
Defined in: core/dist/index.d.mts:1258
Parameters​
option?​
Partial<HoverOption>
Returns​
Promise<void>
Inherited from​
mouseUp()​
protectedmouseUp(option?):Promise<void>
Defined in: core/dist/index.d.mts:1257
Parameters​
option?​
Partial<MouseUpOption>
Returns​
Promise<void>
Inherited from​
scrollBy()​
protectedscrollBy(delta):Promise<void>
Defined in: 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>