@atomic-testing/component-driver-html
Version:
HTML component driver for atomic-testing
257 lines (256 loc) • 8.29 kB
TypeScript
import { ClickOption, ComponentDriver, HoverOption, IClickableDriver, IComponentDriverOption, IFormFieldDriver, IInputDriver, IMouseInteractableDriver, IToggleDriver, Interactor, Nullable, Optional, PartLocator } from "@atomic-testing/core";
//#region src/components/HTMLAnchorDriver.d.ts
declare class HTMLAnchorDriver extends ComponentDriver<{}> implements IClickableDriver, IMouseInteractableDriver {
/**
* Trigger a click on the anchor element.
*/
click(option?: ClickOption): Promise<void>;
/**
* Hover over the anchor element.
*/
hover(option?: HoverOption): Promise<void>;
/**
* Retrieve the link's `href` attribute.
*/
getHref(): Promise<Optional<string>>;
/**
* Retrieve the link's `target` attribute.
*/
getTarget(): Promise<Optional<string>>;
/**
* Identifier for this driver.
*/
get driverName(): string;
}
//#endregion
//#region src/components/HTMLButtonDriver.d.ts
declare class HTMLButtonDriver extends ComponentDriver<{}> implements IClickableDriver, IMouseInteractableDriver {
/**
* Check if the button element is disabled.
*
* @returns A promise that resolves to `true` when the underlying
* `disabled` attribute is present.
*/
isDisabled(): Promise<boolean>;
/**
* Identifier for this driver. Primarily used by debugging utilities.
*/
get driverName(): string;
}
//#endregion
//#region src/components/HTMLCheckboxDriver.d.ts
declare class HTMLCheckboxDriver extends ComponentDriver<{}> implements IFormFieldDriver<string | null>, IToggleDriver {
/**
* Read the checkbox value attribute.
*
* @returns The value assigned to the checkbox or `null` when the attribute is
* not present.
*/
getValue(): Promise<string | null>;
/**
* Determine if the checkbox is currently checked.
*/
isSelected(): Promise<boolean>;
/**
* Change the checked state of the checkbox.
*
* @param selected Desired checked state.
*/
setSelected(selected: boolean): Promise<void>;
/**
* Check whether the checkbox element is disabled.
*/
isDisabled(): Promise<boolean>;
/**
* Check whether the checkbox is read only.
*/
isReadonly(): Promise<boolean>;
/**
* Identifier for this driver.
*/
get driverName(): string;
}
//#endregion
//#region src/components/HTMLCheckboxGroupDriver.d.ts
declare class HTMLCheckboxGroupDriver extends ComponentDriver<{}> implements IInputDriver<readonly string[]> {
/**
* Retrieve the list of values currently selected within the group.
*
* Iterates over every checkbox rather than relying on a CSS selector so that
* an empty selection does not cause a driver error.
*/
getValue(): Promise<readonly string[]>;
/**
* Select or deselect checkboxes so that their combined values equal the
* provided list.
*
* @param values Values that should be selected after the operation.
* @returns Always resolves to `true` once the selection has been adjusted.
*/
setValue(values: readonly string[]): Promise<boolean>;
/**
* Helper used by {@link setValue} to change the checked state of a checkbox
* with a specific value.
*/
protected setSelectedByValue(value: string, selected: boolean): Promise<void>;
/**
* Identifier for this driver.
*/
get driverName(): string;
}
//#endregion
//#region src/components/HTMLElementDriver.d.ts
/**
* Generic HTML element driver for non-interactive elements
*/
declare class HTMLElementDriver extends ComponentDriver<{}> {
/**
* Identifier for this driver.
*/
get driverName(): string;
}
//#endregion
//#region src/components/HTMLHiddenInputDriver.d.ts
declare class HTMLHiddenInputDriver extends ComponentDriver<{}> implements IInputDriver<string | null> {
/**
* Create a driver for a hidden input element.
*/
constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>);
/**
* Retrieve the value attribute of the hidden input.
*/
getValue(): Promise<string | null>;
/**
* Setting the value of a hidden input is not supported.
*/
setValue(_value: string | null): Promise<boolean>;
/**
* Identifier for this driver.
*/
get driverName(): string;
}
//#endregion
//#region src/components/HTMLOptionDriver.d.ts
declare class HTMLOptionDriver extends ComponentDriver {
/**
* Text content of the option element.
*/
label(): Promise<string | null>;
/**
* Value attribute for the option element.
*
* When no explicit value is set, the trimmed label is returned.
*/
value(): Promise<string | null>;
/**
* Identifier for this driver.
*/
get driverName(): string;
}
//#endregion
//#region src/components/HTMLRadioButtonGroupDriver.d.ts
declare class HTMLRadioButtonGroupDriver extends ComponentDriver<{}> implements IInputDriver<string | null> {
/**
* Get the value of the currently selected radio button in the group.
*/
getValue(): Promise<string | null>;
/**
* Select the radio button with the specified value.
*
* @param value Value attribute of the radio button to select.
*/
setValue(value: string | null): Promise<boolean>;
/**
* Identifier for this driver.
*/
get driverName(): string;
}
//#endregion
//#region src/components/HTMLSelectDriver.d.ts
type ValueT = string | readonly string[];
declare class HTMLSelectDriver extends ComponentDriver<{}> implements IInputDriver<Nullable<ValueT>> {
/**
* Determine whether the select element allows multiple selections.
*/
isMultiple(): Promise<boolean>;
/**
* Get the current value(s) of the select element.
*
* @returns `null` when nothing is selected, otherwise the selected value or
* array of values depending on the `multiple` attribute.
*/
getValue(): Promise<Nullable<ValueT>>;
/**
* Select one or more options based on their value attribute.
*
* @param value Value or list of values to select. Use `null` to clear the
* selection.
*/
setValue(value: Nullable<ValueT>): Promise<boolean>;
/**
* Resolve option values from their visible labels.
*/
getValuesByLabels(labels: readonly string[]): Promise<readonly string[]>;
/**
* Select option(s) using their labels rather than values.
*/
selectByLabel(label: string | readonly string[]): Promise<void>;
getSelectedLabel(isMultiple: true): Promise<readonly string[] | null>;
getSelectedLabel(isMultiple: false): Promise<string | null>;
getSelectedLabel(): Promise<string | null>;
/**
* Check whether the select element is disabled.
*/
isDisabled(): Promise<boolean>;
/**
* Check whether the select element is read only.
*/
isReadonly(): Promise<boolean>;
/**
* Identifier for this driver.
*/
get driverName(): string;
}
//#endregion
//#region src/components/HTMLTextInputDriver.d.ts
declare class HTMLTextInputDriver extends ComponentDriver<{}> implements IInputDriver<string | null> {
/**
* Create a text input driver.
*/
constructor(locator: PartLocator, interactor: Interactor, option?: Partial<IComponentDriverOption>);
/**
* Read the value of the input element.
*/
getValue(): Promise<string | null>;
/**
* Set the value of the input, if the input is date, the value should be in the format of 'yyyy-MM-dd'.
* If the input is time, the value should be in the format of 'HH:mm:'.
* If the input is datetime-local, the value should be in the format of 'yyyy-MM-ddTHH:mm'.
* @param value Value to be set.
* @returns
*/
setValue(value: string | null): Promise<boolean>;
/**
* Check whether the text input is disabled.
*/
isDisabled(): Promise<boolean>;
/**
* Check whether the text input is read only.
*/
isReadonly(): Promise<boolean>;
/**
* Identifier for this driver.
*/
get driverName(): string;
}
//#endregion
//#region src/components/HTMLTextAreaDriver.d.ts
declare class HTMLTextAreaDriver extends HTMLTextInputDriver {
/**
* Identifier for this driver.
*/
get driverName(): string;
}
//#endregion
export { HTMLAnchorDriver, HTMLButtonDriver, HTMLCheckboxDriver, HTMLCheckboxGroupDriver, HTMLElementDriver, HTMLHiddenInputDriver, HTMLOptionDriver, HTMLRadioButtonGroupDriver, HTMLSelectDriver, HTMLTextAreaDriver, HTMLTextInputDriver };
//# sourceMappingURL=index.d.ts.map