Skip to main content

Class: ListComponentDriver<ItemT>

@atomic-testing/core.ListComponentDriver

Base class for all component drivers. It provides the basic functionality to interact with the component

Type parameters

NameType
ItemTextends ComponentDriver

Hierarchy

Constructors

constructor

new ListComponentDriver<ItemT>(locator, interactor, option): ListComponentDriver<ItemT>

Type parameters

NameType
ItemTextends ComponentDriver<>

Parameters

NameType
locatorPartLocator
interactorInteractor
optionListComponentDriverSpecificOption<ItemT>

Returns

ListComponentDriver<ItemT>

Overrides

ComponentDriver.constructor

Defined in

packages/core/src/drivers/ListComponentDriver.ts:20

Properties

_itemLocator

Private _itemLocator: PartLocator

Defined in

packages/core/src/drivers/ListComponentDriver.ts:19


_option

Private Readonly _option: ListComponentDriverSpecificOption<ItemT> & Partial<ListComponentDriverOption<ItemT>>

Defined in

packages/core/src/drivers/ListComponentDriver.ts:18


commutableOption

Readonly commutableOption: IComponentDriverOption<>

Option passed to the constructor includes both universal options which can be shared across all component driver tree, and component specific options which are only applicable to the component.

Commutable option is the option that can be shared across all component driver tree.

Inherited from

ComponentDriver.commutableOption

Defined in

packages/core/src/drivers/ComponentDriver.ts:35


interactor

Readonly interactor: Interactor

Inherited from

ComponentDriver.interactor

Defined in

packages/core/src/drivers/ComponentDriver.ts:39

Accessors

driverName

get driverName(): string

Returns

string

Overrides

ComponentDriver.driverName

Defined in

packages/core/src/drivers/ListComponentDriver.ts:91


locator

get locator(): PartLocator

Return the locator of the component

Returns

PartLocator

Inherited from

ComponentDriver.locator

Defined in

packages/core/src/drivers/ComponentDriver.ts:88


parts

get parts(): ScenePartDriver<T>

Return driver instance of all the named parts

Returns

ScenePartDriver<T>

Inherited from

ComponentDriver.parts

Defined in

packages/core/src/drivers/ComponentDriver.ts:81

Methods

click

click(option?): Promise<void>

Parameters

NameType
option?Partial<ClickOption>

Returns

Promise<void>

Inherited from

ComponentDriver.click

Defined in

packages/core/src/drivers/ComponentDriver.ts:155


enforcePartExistence

enforcePartExistence(partName): Promise<void>

Check the specified parts' existences, and throw MissPartError 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

NameTypeDescription
partNamereadonly never[]Single or array of the names of the parts to be enforced

Returns

Promise<void>

Inherited from

ComponentDriver.enforcePartExistence

Defined in

packages/core/src/drivers/ComponentDriver.ts:97


exists

exists(): Promise<boolean>

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

Defined in

packages/core/src/drivers/ComponentDriver.ts:151


focus

focus(option?): Promise<void>

Parameters

NameType
option?Partial<FocusOption>

Returns

Promise<void>

Inherited from

ComponentDriver.focus

Defined in

packages/core/src/drivers/ComponentDriver.ts:191


getAttribute

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

Parameters

NameType
attributeNamestring

Returns

Promise<Optional<string>>

Inherited from

ComponentDriver.getAttribute

Defined in

packages/core/src/drivers/ComponentDriver.ts:143


getItemByIndex

getItemByIndex<ItemClass>(index, itemDriverClass?): Promise<null | ItemClass>

Get the item's driver instance at the given index

Type parameters

NameType
ItemClassextends ComponentDriver<> = ItemT

Parameters

NameType
indexnumber
itemDriverClass?ItemClass

Returns

Promise<null | ItemClass>

The item's driver instance at the given index, if the index is out of range, return null

Defined in

packages/core/src/drivers/ListComponentDriver.ts:45


getItemByLabel

getItemByLabel<ItemClass>(text, itemDriverClass?): Promise<null | ItemClass>

Get the item's driver instance by the given text

Type parameters

NameType
ItemClassextends ComponentDriver<> = ItemT

Parameters

NameType
textstring
itemDriverClass?ItemClass

Returns

Promise<null | ItemClass>

The item's driver instance by the given text, if the text is not found, return null

Defined in

packages/core/src/drivers/ListComponentDriver.ts:60


getItemClass

getItemClass<ItemClass>(itemDriverClass?): ItemClass

Type parameters

NameType
ItemClassextends ComponentDriver<> = ItemT

Parameters

NameType
itemDriverClass?ItemClass

Returns

ItemClass

Defined in

packages/core/src/drivers/ListComponentDriver.ts:35


getItemLocator

getItemLocator(): PartLocator

Returns

PartLocator

Defined in

packages/core/src/drivers/ListComponentDriver.ts:31


getItems

getItems<ItemClass>(itemDriverClass?): Promise<ItemClass[]>

Get all the items' driver instances in the list

Type parameters

NameType
ItemClassextends ComponentDriver<> = ItemT

Parameters

NameType
itemDriverClass?ItemClass

Returns

Promise<ItemClass[]>

Defined in

packages/core/src/drivers/ListComponentDriver.ts:81


getMissingPartNames

getMissingPartNames(partName): Promise<readonly never[]>

Get the names of parts not in the DOM

Parameters

NameTypeDescription
partNamereadonly never[]Single or array of the names of the parts to be examined

Returns

Promise<readonly never[]>

Inherited from

ComponentDriver.getMissingPartNames

Defined in

packages/core/src/drivers/ComponentDriver.ts:110


getText

getText(): Promise<Optional<string>>

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

Defined in

packages/core/src/drivers/ComponentDriver.ts:139


hover

hover(option?): Promise<void>

Parameters

NameType
option?Partial<HoverOption>

Returns

Promise<void>

Inherited from

ComponentDriver.hover

Defined in

packages/core/src/drivers/ComponentDriver.ts:159


isVisible

isVisible(): Promise<boolean>

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 wether the component is within the viewport.

Returns

Promise<boolean>

true if the component is visible, false otherwise

Inherited from

ComponentDriver.isVisible

Defined in

packages/core/src/drivers/ComponentDriver.ts:203


mouseDown

mouseDown(option?): Promise<void>

Parameters

NameType
option?Partial<MouseDownOption>

Returns

Promise<void>

Inherited from

ComponentDriver.mouseDown

Defined in

packages/core/src/drivers/ComponentDriver.ts:167


mouseEnter

mouseEnter(option?): Promise<void>

Parameters

NameType
option?Partial<MouseEnterOption>

Returns

Promise<void>

Inherited from

ComponentDriver.mouseEnter

Defined in

packages/core/src/drivers/ComponentDriver.ts:183


mouseLeave

mouseLeave(option?): Promise<void>

Parameters

NameType
option?Partial<MouseLeaveOption>

Returns

Promise<void>

Inherited from

ComponentDriver.mouseLeave

Defined in

packages/core/src/drivers/ComponentDriver.ts:187


mouseMove

mouseMove(option?): Promise<void>

Parameters

NameType
option?Partial<MouseMoveOption>

Returns

Promise<void>

Inherited from

ComponentDriver.mouseMove

Defined in

packages/core/src/drivers/ComponentDriver.ts:163


mouseOut

mouseOut(option?): Promise<void>

Parameters

NameType
option?Partial<MouseOutOption>

Returns

Promise<void>

Inherited from

ComponentDriver.mouseOut

Defined in

packages/core/src/drivers/ComponentDriver.ts:179


mouseOver

mouseOver(option?): Promise<void>

Parameters

NameType
option?Partial<HoverOption>

Returns

Promise<void>

Inherited from

ComponentDriver.mouseOver

Defined in

packages/core/src/drivers/ComponentDriver.ts:175


mouseUp

mouseUp(option?): Promise<void>

Parameters

NameType
option?Partial<MouseUpOption>

Returns

Promise<void>

Inherited from

ComponentDriver.mouseUp

Defined in

packages/core/src/drivers/ComponentDriver.ts:171


overriddenParentLocator

overriddenParentLocator(): Optional<PartLocator>

Usually this should be undefined as the component driver corresponds to a component nested inside the parent DOM, thus the driver's locator would automatically chain with its parent's locator.

When the component is rendered outside the parent's DOM, which usually happens when the component is a modal or popup, supply the PartLocator on how to locate the component with the component's own locator.

Caution of usage: this function is called before the construction of the driver, so it should not use any instance properties

Returns

Optional<PartLocator>

Inherited from

ComponentDriver.overriddenParentLocator

Defined in

packages/core/src/drivers/ComponentDriver.ts:59


overrideLocatorRelativePosition

overrideLocatorRelativePosition(): Optional<LocatorRelativePosition>

Usually this should be undefined when the locator is defined by the ScenePart, thus it reflects the natural relative position of the component

However, in some implementation such as MUI v5 dialog, the actual dialog DOM is rendered outside the parent DOM, and the selector is "siblings", by defining this function, it allows the driver to have the knowledge of the actual relative position instead of offloading the knowledge to the consumer.

Caution of usage: this function is called before the construction of the driver, so it should not use any instance properties

Returns

Optional<LocatorRelativePosition>

Inherited from

ComponentDriver.overrideLocatorRelativePosition

Defined in

packages/core/src/drivers/ComponentDriver.ts:74


waitUntil

waitUntil(option?): Promise<void>

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

NameTypeDefault valueDescription
optionPartial<Readonly<WaitForOption>>defaultWaitForOptionThe option to configure the wait behavior

Returns

Promise<void>

Inherited from

ComponentDriver.waitUntil

Defined in

packages/core/src/drivers/ComponentDriver.ts:218