Options
All
  • Public
  • Public/Protected
  • All
Menu

@interactors/html - v0.34.0

Index

Type aliases

InteractorSpecification

InteractorSpecification<E, F, A>: { actions?: A; filters?: F; locator?: LocatorFn<E>; selector?: string }

Type parameters

  • E: Element

  • F: Filters<E>

  • A: Actions<E>

Type declaration

  • Optional actions?: A
  • Optional filters?: F
  • Optional locator?: LocatorFn<E>

    A function which returns a string value for a matched element, which can be used to locate a specific instance of this interactor. The value parameter of an InteractorConstructor must match the value returned from the locator function.

  • Optional selector?: string

    The CSS selector that this interactor uses to find matching elements

Interactor Variables

Button

Button: InteractorConstructor<HTMLInputElement | HTMLButtonElement, MergeObjects<MergeObjects<EmptyObject, { classList: undefined | MaybeMatcher<string[]>; className: undefined | MaybeMatcher<string>; focused: undefined | MaybeMatcher<boolean>; id: undefined | MaybeMatcher<string>; text: undefined | MaybeMatcher<string>; title: undefined | MaybeMatcher<string>; visible: undefined | MaybeMatcher<boolean> }>, { disabled: undefined | MaybeMatcher<boolean> }>, MergeObjects<MergeObjects<EmptyObject, FilterMethods<HTMLElement, { classList: (element: HTMLElement) => string[]; className: (element: HTMLElement) => string; focused: (element: HTMLElement) => boolean; id: (element: HTMLElement) => string; text: (element?: HTMLElement) => string; title: (element: HTMLElement) => string; visible: { apply: (elem: HTMLElement) => boolean; default: boolean } }>>, FilterMethods<HTMLInputElement | HTMLButtonElement, { disabled: { apply: (element: HTMLInputElement | HTMLButtonElement) => boolean; default: boolean } }>>, MergeObjects<EmptyObject, ActionMethods<HTMLElement, { blur: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void>; click: (__namedParameters: Interactor<HTMLElement, EmptyObject>, init?: MouseEventInit) => Interaction<void>; focus: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void> }>>> = ButtonInteractor

Call this InteractorConstructor to initialize a button Interactor. The button interactor can be used to interact with buttons on the page and to assert on their state.

The button is located by the visible text on the button.

Example

await Button('Submit').click();
await Button('Submit').is({ disabled: true });
await Button({ id: 'submit-button', disabled: true }).exists();

Filters

  • title: string – Filter by title
  • id: string – Filter by id
  • visible: boolean – Filter by visibility. Defaults to true. See isVisible.
  • disabled: boolean – Filter by whether the button is disabled. Defaults to false.
  • focused: boolean – Filter by whether the button is focused. See focused.

Actions

CheckBox

CheckBox: InteractorConstructor<HTMLInputElement, MergeObjects<MergeObjects<MergeObjects<EmptyObject, { classList: undefined | MaybeMatcher<string[]>; className: undefined | MaybeMatcher<string>; focused: undefined | MaybeMatcher<boolean>; id: undefined | MaybeMatcher<string>; text: undefined | MaybeMatcher<string>; title: undefined | MaybeMatcher<string>; visible: undefined | MaybeMatcher<boolean> }>, { disabled: undefined | MaybeMatcher<boolean>; valid: undefined | MaybeMatcher<boolean> }>, { checked: undefined | MaybeMatcher<boolean>; indeterminate: undefined | MaybeMatcher<boolean>; visible: undefined | MaybeMatcher<null | boolean> }>, MergeObjects<MergeObjects<MergeObjects<EmptyObject, FilterMethods<HTMLElement, { classList: (element: HTMLElement) => string[]; className: (element: HTMLElement) => string; focused: (element: HTMLElement) => boolean; id: (element: HTMLElement) => string; text: (element?: HTMLElement) => string; title: (element: HTMLElement) => string; visible: { apply: (elem: HTMLElement) => boolean; default: boolean } }>>, FilterMethods<FieldTypes, { disabled: { apply: (element: FieldTypes) => boolean; default: boolean }; valid: (element: FieldTypes) => boolean }>>, FilterMethods<HTMLInputElement, { checked: (element: HTMLInputElement) => boolean; indeterminate: (element: HTMLInputElement) => boolean; visible: { apply: (element: HTMLInputElement) => null | boolean; default: boolean } }>>, MergeObjects<MergeObjects<EmptyObject, ActionMethods<HTMLElement, { blur: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void>; click: (__namedParameters: Interactor<HTMLElement, EmptyObject>, init?: MouseEventInit) => Interaction<void>; focus: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void> }>>, ActionMethods<HTMLInputElement, { check: (__namedParameters: Interactor<HTMLInputElement, EmptyObject>) => Interaction<void>; toggle: (__namedParameters: Interactor<HTMLInputElement, EmptyObject>) => Interaction<void>; uncheck: (__namedParameters: Interactor<HTMLInputElement, EmptyObject>) => Interaction<void> }>>> = CheckBoxInteractor

Call this InteractorConstructor to initialize a checkbox Interactor. The checkbox interactor can be used to interact with checkboxes on the page and to assert on their state.

The checkbox is located by the text of its label.

Example

await CheckBox('Accept').check();
await CheckBox('Accept').is({ disabled: true });
await CheckBox({ id: 'accept', disabled: true }).exists();

Filters

  • title: string – Filter by title
  • id: string – Filter by id
  • visible: boolean – Filter by visibility. Defaults to true. See isVisible.
  • valid: boolean – Filter by whether the checkbox is valid.
  • checked: boolean – Filter by whether the checkbox is checked.
  • indeterminate: boolean - Filter by whether the checkbox has indeterminate state.
  • disabled: boolean – Filter by whether the checkbox is disabled. Defaults to false.
  • focused: boolean – Filter by whether the checkbox is focused. See focused.

Actions

FormField

FormField: InteractorConstructor<FieldTypes, MergeObjects<MergeObjects<EmptyObject, { classList: undefined | MaybeMatcher<string[]>; className: undefined | MaybeMatcher<string>; focused: undefined | MaybeMatcher<boolean>; id: undefined | MaybeMatcher<string>; text: undefined | MaybeMatcher<string>; title: undefined | MaybeMatcher<string>; visible: undefined | MaybeMatcher<boolean> }>, { disabled: undefined | MaybeMatcher<boolean>; valid: undefined | MaybeMatcher<boolean> }>, MergeObjects<MergeObjects<EmptyObject, FilterMethods<HTMLElement, { classList: (element: HTMLElement) => string[]; className: (element: HTMLElement) => string; focused: (element: HTMLElement) => boolean; id: (element: HTMLElement) => string; text: (element?: HTMLElement) => string; title: (element: HTMLElement) => string; visible: { apply: (elem: HTMLElement) => boolean; default: boolean } }>>, FilterMethods<FieldTypes, { disabled: { apply: (element: FieldTypes) => boolean; default: boolean }; valid: (element: FieldTypes) => boolean }>>, MergeObjects<EmptyObject, ActionMethods<HTMLElement, { blur: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void>; click: (__namedParameters: Interactor<HTMLElement, EmptyObject>, init?: MouseEventInit) => Interaction<void>; focus: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void> }>>> = FormFieldInteractor

Use this InteractorConstructor as a base for creating interactors which work with form fields. This allows you to use field labels as locators, and also provides some basic filters which are convenient for most form fields.

Locates the form field by its label.

Example

const PasswordField = FormField.extend<HTMLInputElement>('password field')
.selector('input[type=password'])
.filters({
value: (element) => element.value,
placeholder: (element) => element.placeholder,
})

Filters

  • title: string – Filter by title
  • id: string – Filter by id
  • visible: boolean – Filter by visibility. Defaults to true. See isVisible.
  • focused: boolean – Filter by whether the form field is focused. See focused.
  • valid: boolean – Filter by whether the form field is valid.
  • disabled: boolean – Filter by whether the form field is disabled. Defaults to false.

Actions

HTML

HTML: InteractorConstructor<HTMLElement, MergeObjects<EmptyObject, { classList: undefined | MaybeMatcher<string[]>; className: undefined | MaybeMatcher<string>; focused: undefined | MaybeMatcher<boolean>; id: undefined | MaybeMatcher<string>; text: undefined | MaybeMatcher<string>; title: undefined | MaybeMatcher<string>; visible: undefined | MaybeMatcher<boolean> }>, MergeObjects<EmptyObject, FilterMethods<HTMLElement, { classList: (element: HTMLElement) => string[]; className: (element: HTMLElement) => string; focused: (element: HTMLElement) => boolean; id: (element: HTMLElement) => string; text: (element?: HTMLElement) => string; title: (element: HTMLElement) => string; visible: { apply: (elem: HTMLElement) => boolean; default: boolean } }>>, MergeObjects<EmptyObject, ActionMethods<HTMLElement, { blur: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void>; click: (__namedParameters: Interactor<HTMLElement, EmptyObject>, init?: MouseEventInit) => Interaction<void>; focus: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void> }>>> = HTMLInteractor

Use this InteractorConstructor as a base for creating interactors which work with HTML elements. This provides some basic functionality which is convenient for most HTML elements.

Example

const Link = HTML.extend<HTMLLinkElement>('link')
.selector('a[href]')
.filters({
href: (element) => element.href
})

Filters

  • classList: string[] — Filter by the list of classes found in element's className
  • className: string — Filter by element's className
  • title: string – Filter by title
  • id: string – Filter by id
  • text: string – Filter by the text content of this element.
  • visible: boolean – Filter by visibility. Defaults to true. See isVisible.
  • focused: boolean – Filter by whether the element is focused. See focused.

Actions

Heading

Heading: InteractorConstructor<HTMLHeadingElement, MergeObjects<MergeObjects<EmptyObject, { classList: undefined | MaybeMatcher<string[]>; className: undefined | MaybeMatcher<string>; focused: undefined | MaybeMatcher<boolean>; id: undefined | MaybeMatcher<string>; text: undefined | MaybeMatcher<string>; title: undefined | MaybeMatcher<string>; visible: undefined | MaybeMatcher<boolean> }>, { level: undefined | MaybeMatcher<number> }>, MergeObjects<MergeObjects<EmptyObject, FilterMethods<HTMLElement, { classList: (element: HTMLElement) => string[]; className: (element: HTMLElement) => string; focused: (element: HTMLElement) => boolean; id: (element: HTMLElement) => string; text: (element?: HTMLElement) => string; title: (element: HTMLElement) => string; visible: { apply: (elem: HTMLElement) => boolean; default: boolean } }>>, FilterMethods<HTMLHeadingElement, { level: (element: HTMLHeadingElement) => number }>>, MergeObjects<EmptyObject, ActionMethods<HTMLElement, { blur: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void>; click: (__namedParameters: Interactor<HTMLElement, EmptyObject>, init?: MouseEventInit) => Interaction<void>; focus: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void> }>>> = HeadingInteractor

Call this InteractorConstructor to initialize a heading Interactor. The heading interactor can be used to assert on the state of headings on the page, represented by the h1 through h6 tags.

Example

await Heading('Welcome!').exists();

Filters

  • level: number – The level of the heading, for example, the level of h3 is 3.
  • visible: boolean – Filter by visibility. Defaults to true. See isVisible.

Link

Link: InteractorConstructor<HTMLLinkElement, MergeObjects<MergeObjects<EmptyObject, { classList: undefined | MaybeMatcher<string[]>; className: undefined | MaybeMatcher<string>; focused: undefined | MaybeMatcher<boolean>; id: undefined | MaybeMatcher<string>; text: undefined | MaybeMatcher<string>; title: undefined | MaybeMatcher<string>; visible: undefined | MaybeMatcher<boolean> }>, { href: undefined | MaybeMatcher<string> }>, MergeObjects<MergeObjects<EmptyObject, FilterMethods<HTMLElement, { classList: (element: HTMLElement) => string[]; className: (element: HTMLElement) => string; focused: (element: HTMLElement) => boolean; id: (element: HTMLElement) => string; text: (element?: HTMLElement) => string; title: (element: HTMLElement) => string; visible: { apply: (elem: HTMLElement) => boolean; default: boolean } }>>, FilterMethods<HTMLLinkElement, { href: (element: HTMLLinkElement) => string }>>, MergeObjects<EmptyObject, ActionMethods<HTMLElement, { blur: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void>; click: (__namedParameters: Interactor<HTMLElement, EmptyObject>, init?: MouseEventInit) => Interaction<void>; focus: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void> }>>> = LinkInteractor

Call this InteractorConstructor to initialize a link Interactor. The link interactor can be used to interact with links on the page and to assert on their state.

The link is located by its text.

Example

await Link('Home').click();
await Link('Home').has({ href: '/' });
await Link({ id: 'home-link', href: '/' }).exists();

Filters

  • title: string – Filter by title
  • id: string – Filter by id
  • href: string – The value of the href attribute that the link points to
  • visible: boolean – Filter by visibility. Defaults to true. See isVisible.
  • focused: boolean – Filter by whether the link is focused. See focused.

Actions

MultiSelect

MultiSelect: InteractorConstructor<HTMLSelectElement, MergeObjects<MergeObjects<MergeObjects<EmptyObject, { classList: undefined | MaybeMatcher<string[]>; className: undefined | MaybeMatcher<string>; focused: undefined | MaybeMatcher<boolean>; id: undefined | MaybeMatcher<string>; text: undefined | MaybeMatcher<string>; title: undefined | MaybeMatcher<string>; visible: undefined | MaybeMatcher<boolean> }>, { disabled: undefined | MaybeMatcher<boolean>; valid: undefined | MaybeMatcher<boolean> }>, { values: undefined | MaybeMatcher<string[]> }>, MergeObjects<MergeObjects<MergeObjects<EmptyObject, FilterMethods<HTMLElement, { classList: (element: HTMLElement) => string[]; className: (element: HTMLElement) => string; focused: (element: HTMLElement) => boolean; id: (element: HTMLElement) => string; text: (element?: HTMLElement) => string; title: (element: HTMLElement) => string; visible: { apply: (elem: HTMLElement) => boolean; default: boolean } }>>, FilterMethods<FieldTypes, { disabled: { apply: (element: FieldTypes) => boolean; default: boolean }; valid: (element: FieldTypes) => boolean }>>, FilterMethods<HTMLSelectElement, { values: (element: HTMLSelectElement) => string[] }>>, MergeObjects<MergeObjects<EmptyObject, ActionMethods<HTMLElement, { blur: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void>; click: (__namedParameters: Interactor<HTMLElement, EmptyObject>, init?: MouseEventInit) => Interaction<void>; focus: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void> }>>, ActionMethods<HTMLSelectElement, { choose: (interactor: Interactor<HTMLSelectElement, EmptyObject>, text: string) => Promise<void>; deselect: (interactor: Interactor<HTMLSelectElement, EmptyObject>, text: string) => Promise<void>; select: (interactor: Interactor<HTMLSelectElement, EmptyObject>, text: string) => Promise<void> }>>> = MultiSelectInteractor

Call this InteractorConstructor to initialize an Interactor for select boxes with multiple select. The multi select interactor can be used to interact with select boxes with the multiple attribute and to assert on their state.

See Select for an interactor for single select boxes.

The multi select is located by the text of its label.

Example

await MultiSelect('Language').select('English');
await MultiSelect('Language').select('German');
await MultiSelect('Language').deselect('Swedish');
await MultiSelect('Language').has({ values: ['English', 'German'] });

Filters

  • title: string – Filter by title
  • id: string – Filter by id
  • valid: boolean – Filter by whether the select box is valid.
  • values: string[] – Filter by the text of the selected options.
  • visible: boolean – Filter by visibility. Defaults to true. See isVisible.
  • disabled: boolean – Filter by whether the select box is disabled. Defaults to false.
  • focused: boolean – Filter by whether the select box is focused. See focused.

Actions

  • click(): Interaction – Click on the multi select
  • focus(): Interaction – Move focus to the multi select
  • blur(): Interaction – Move focus away from the multi select
  • choose(text: string): Interaction – Choose the option with the given text from the multi select. Will deselect all other selected options.
  • select(text: string): Interaction – Add the option with the given text to the selection.
  • deselect(text: string): Interaction – Remove the option with the given text from the selection.

Page

Page: Interactor<Element, MergeObjects<EmptyObject, { title: undefined | MaybeMatcher<string>; url: undefined | MaybeMatcher<string> }>> & FilterMethods<Element, { title: (element: Element) => string; url: (element: Element) => string }> & Omit<EmptyObject, "title" | "url"> & EmptyObject & { visit: any } = PageInteractorInstance

This Interactor can be used to assert on global properties of the page. When using the BigTest test runner, it can also be used for interacting with the page itself, for example through nagivation.

Example

await Page.has({ title: 'Welcome to my app!' });

Navigation, for BigTest test runner only:

await Page.visit('/archive');

Filters

  • title: string – the title of the document
  • url: string – the URL of the document

Actions

  • visit(path: string): Interaction – visit the given path in the test frame, BigTest runner only.

RadioButton

RadioButton: InteractorConstructor<HTMLInputElement, MergeObjects<MergeObjects<MergeObjects<EmptyObject, { classList: undefined | MaybeMatcher<string[]>; className: undefined | MaybeMatcher<string>; focused: undefined | MaybeMatcher<boolean>; id: undefined | MaybeMatcher<string>; text: undefined | MaybeMatcher<string>; title: undefined | MaybeMatcher<string>; visible: undefined | MaybeMatcher<boolean> }>, { disabled: undefined | MaybeMatcher<boolean>; valid: undefined | MaybeMatcher<boolean> }>, { checked: undefined | MaybeMatcher<boolean>; visible: undefined | MaybeMatcher<null | boolean> }>, MergeObjects<MergeObjects<MergeObjects<EmptyObject, FilterMethods<HTMLElement, { classList: (element: HTMLElement) => string[]; className: (element: HTMLElement) => string; focused: (element: HTMLElement) => boolean; id: (element: HTMLElement) => string; text: (element?: HTMLElement) => string; title: (element: HTMLElement) => string; visible: { apply: (elem: HTMLElement) => boolean; default: boolean } }>>, FilterMethods<FieldTypes, { disabled: { apply: (element: FieldTypes) => boolean; default: boolean }; valid: (element: FieldTypes) => boolean }>>, FilterMethods<HTMLInputElement, { checked: (element: HTMLInputElement) => boolean; visible: { apply: (element: HTMLInputElement) => null | boolean; default: boolean } }>>, MergeObjects<MergeObjects<EmptyObject, ActionMethods<HTMLElement, { blur: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void>; click: (__namedParameters: Interactor<HTMLElement, EmptyObject>, init?: MouseEventInit) => Interaction<void>; focus: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void> }>>, ActionMethods<HTMLInputElement, { choose: (__namedParameters: Interactor<HTMLInputElement, EmptyObject>) => Interaction<void> }>>> = RadioButtonInteractor

Call this InteractorConstructor to initialize a radio button Interactor. The radio button interactor can be used to interact with radio buttons on the page and to assert on their state.

The radio button is located by the text of its label.

Example

await RadioButton('Public').click();
await RadioButton('Private').is({ disabled: true });
await RadioButton({ id: 'privacy-public', disabled: true }).exists();

Filters

  • title: string – Filter by title
  • id: string – Filter by id
  • visible: boolean – Filter by visibility. Defaults to true. See isVisible.
  • valid: boolean – Filter by whether the radio button is valid.
  • checked: boolean – Filter by whether the radio button is checked.
  • disabled: boolean – Filter by whether the radio button is disabled. Defaults to false.
  • focused: boolean – Filter by whether the radio button is focused. See focused.

Actions

Select

Select: InteractorConstructor<HTMLSelectElement, MergeObjects<MergeObjects<MergeObjects<EmptyObject, { classList: undefined | MaybeMatcher<string[]>; className: undefined | MaybeMatcher<string>; focused: undefined | MaybeMatcher<boolean>; id: undefined | MaybeMatcher<string>; text: undefined | MaybeMatcher<string>; title: undefined | MaybeMatcher<string>; visible: undefined | MaybeMatcher<boolean> }>, { disabled: undefined | MaybeMatcher<boolean>; valid: undefined | MaybeMatcher<boolean> }>, { value: undefined | MaybeMatcher<string> }>, MergeObjects<MergeObjects<MergeObjects<EmptyObject, FilterMethods<HTMLElement, { classList: (element: HTMLElement) => string[]; className: (element: HTMLElement) => string; focused: (element: HTMLElement) => boolean; id: (element: HTMLElement) => string; text: (element?: HTMLElement) => string; title: (element: HTMLElement) => string; visible: { apply: (elem: HTMLElement) => boolean; default: boolean } }>>, FilterMethods<FieldTypes, { disabled: { apply: (element: FieldTypes) => boolean; default: boolean }; valid: (element: FieldTypes) => boolean }>>, FilterMethods<HTMLSelectElement, { value: (element: HTMLSelectElement) => string }>>, MergeObjects<MergeObjects<EmptyObject, ActionMethods<HTMLElement, { blur: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void>; click: (__namedParameters: Interactor<HTMLElement, EmptyObject>, init?: MouseEventInit) => Interaction<void>; focus: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void> }>>, ActionMethods<HTMLSelectElement, { choose: (interactor: Interactor<HTMLSelectElement, EmptyObject>, value: string) => Promise<void> }>>> = SelectInteractor

Call this InteractorConstructor to initialize an Interactor for select boxes. The select interactor can be used to interact with select boxes and to assert on their state.

For interacting with multiple select boxes, see MultiSelect.

The select box is located by the text of its label.

Example

await Select('Language').select('English');
await Select('Language').has({ value: 'English' });

Filters

  • title: string – Filter by title
  • id: string – Filter by id
  • valid: boolean – Filter by whether the select box is valid.
  • value: string – Filter by the text of the selected option.
  • visible: boolean – Filter by visibility. Defaults to true. See isVisible.
  • disabled: boolean – Filter by whether the select box is disabled. Defaults to false.
  • focused: boolean – Filter by whether the select box is focused. See focused.

Actions

  • click(): Interaction – Click on the select box
  • focus(): Interaction – Move focus to the select box
  • blur(): Interaction – Move focus away from the select box
  • choose(text: string): Interaction – Choose the option with the given text from the select box.

TextField

TextField: InteractorConstructor<HTMLInputElement | HTMLTextAreaElement, MergeObjects<MergeObjects<MergeObjects<EmptyObject, { classList: undefined | MaybeMatcher<string[]>; className: undefined | MaybeMatcher<string>; focused: undefined | MaybeMatcher<boolean>; id: undefined | MaybeMatcher<string>; text: undefined | MaybeMatcher<string>; title: undefined | MaybeMatcher<string>; visible: undefined | MaybeMatcher<boolean> }>, { disabled: undefined | MaybeMatcher<boolean>; valid: undefined | MaybeMatcher<boolean> }>, { placeholder: undefined | MaybeMatcher<string>; value: undefined | MaybeMatcher<string> }>, MergeObjects<MergeObjects<MergeObjects<EmptyObject, FilterMethods<HTMLElement, { classList: (element: HTMLElement) => string[]; className: (element: HTMLElement) => string; focused: (element: HTMLElement) => boolean; id: (element: HTMLElement) => string; text: (element?: HTMLElement) => string; title: (element: HTMLElement) => string; visible: { apply: (elem: HTMLElement) => boolean; default: boolean } }>>, FilterMethods<FieldTypes, { disabled: { apply: (element: FieldTypes) => boolean; default: boolean }; valid: (element: FieldTypes) => boolean }>>, FilterMethods<HTMLInputElement | HTMLTextAreaElement, { placeholder: (element: HTMLInputElement | HTMLTextAreaElement) => string; value: (element: HTMLInputElement | HTMLTextAreaElement) => string }>>, MergeObjects<MergeObjects<EmptyObject, ActionMethods<HTMLElement, { blur: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void>; click: (__namedParameters: Interactor<HTMLElement, EmptyObject>, init?: MouseEventInit) => Interaction<void>; focus: (__namedParameters: Interactor<HTMLElement, EmptyObject>) => Interaction<void> }>>, ActionMethods<HTMLInputElement | HTMLTextAreaElement, { fillIn: (__namedParameters: Interactor<HTMLInputElement | HTMLTextAreaElement, EmptyObject>, value: string) => Interaction<void> }>>> = TextFieldInteractor

Call this InteractorConstructor to initialize a text field Interactor. The text field interactor can be used to interact with text fields on the page and to assert on their state. A text field is any input tag with a text-like interface, so input fields with e.g. email or number types are also considered text fields, as is any input field with an unknown type.

The text field is located by the text of its label.

Example

await TextField('Email').fillIn('jonas@example.com');
await TextField('Email').has({ value: 'jonas@example.com' });
await TextField({ id: 'email-field', disabled: true }).exists();

Filters

  • title: string – Filter by title
  • id: string – Filter by id
  • visible: boolean – Filter by visibility. Defaults to true. See isVisible.
  • value: string – Filter by the text field's current value.
  • placeholder: string – Filter by the text field's placeholder attribute.
  • valid: boolean – Filter by whether the text field is valid.
  • disabled: boolean – Filter by whether the text field is disabled. Defaults to false.
  • focused: boolean – Filter by whether the text field is focused. See focused.

Actions

  • click(): Interaction – Click on the text field
  • focus(): Interaction – Move focus to the text field
  • blur(): Interaction – Move focus away from the text field
  • fillIn(value: string): Interaction – Fill in the text field with the given value. See fillIn.

Other Variables

globals

globals: Omit<Globals, "actionWrappers">

Functions

addActionWrapper

  • addActionWrapper<T>(wrapper: (description: string, action: () => Promise<T>, type: ActionType) => () => Promise<T>): () => boolean
  • Type parameters

    • T

    Parameters

    • wrapper: (description: string, action: () => Promise<T>, type: ActionType) => () => Promise<T>
        • (description: string, action: () => Promise<T>, type: ActionType): () => Promise<T>
        • Parameters

          • description: string
          • action: () => Promise<T>
              • (): Promise<T>
              • Returns Promise<T>

          • type: ActionType

          Returns () => Promise<T>

            • (): Promise<T>
            • Returns Promise<T>

    Returns () => boolean

      • (): boolean
      • Returns boolean

and

  • and<T>(...args: MaybeMatcher<T>[]): Matcher<T>
  • Type parameters

    • T

    Parameters

    • Rest ...args: MaybeMatcher<T>[]

    Returns Matcher<T>

blur

  • blur<E>(interactor: Interactor<E, any>): Promise<void>
  • Helper function for blur action, performs element.blur() on the selected element.

    Can be used with object property value shorthand in your interactor actions.

    actions: {
    focus,
    }

    Type parameters

    • E: HTMLElement

    Parameters

    Returns Promise<void>

createInspector

  • createInspector<IC>(constructor: IC, parentElement?: Element): Inspector<IC>
  • Type parameters

    Parameters

    • constructor: IC
    • Optional parentElement: Element

    Returns Inspector<IC>

createInteractor

  • Create a custom interactor with the given name.

    Creating a simple interactor

    let Paragraph = createInteractor('paragraph').selector('p');
    

    Note the double function call!

    Type parameters

    • E: Element

      The type of DOM Element that this interactor operates on. By specifying the element type, actions and filters defined for the interactor can be type checked against the actual element type.

    Parameters

    • name: string

    Returns InteractorConstructor<E, EmptyObject, EmptyObject, EmptyObject>

    You will need to call the returned builder to create an interactor.

every

  • every<T>(expected: MaybeMatcher<T>): Matcher<Iterable<T>>
  • Type parameters

    • T

    Parameters

    • expected: MaybeMatcher<T>

    Returns Matcher<Iterable<T>>

fillIn

  • fillIn(element: TextFieldElement, value: string): void
  • Fill in text into an element by emulating how a user would do it, first focusing the element, then filling in the text letter by letter, generating the appropriate keyboard events.

    Parameters

    • element: TextFieldElement

      The element to fill in text in

    • value: string

      The text value to fill in

    Returns void

focus

  • focus<E>(interactor: Interactor<E, any>): Promise<void>
  • Helper function for focus action, performs element.focus() on the selected element.

    Can be used with object property value shorthand in your interactor actions.

    actions: {
    focus,
    }

    Type parameters

    • E: HTMLElement

    Parameters

    Returns Promise<void>

focused

  • focused(element: Element): boolean
  • Helper function for focused filters, returns whether the given element is focused.

    Parameters

    • element: Element

    Returns boolean

including

  • including(subString: string): Matcher<string>
  • Parameters

    • subString: string

    Returns Matcher<string>

isInteraction

  • Parameters

    • x: unknown

    Returns x is Interaction<unknown>

isVisible

  • isVisible(elem: HTMLElement): boolean
  • Parameters

    • elem: HTMLElement

    Returns boolean

matching

  • matching(regexp: RegExp): Matcher<string>
  • Parameters

    • regexp: RegExp

    Returns Matcher<string>

not

  • not<T>(matcher: MaybeMatcher<T>): Matcher<T>
  • Type parameters

    • T

    Parameters

    • matcher: MaybeMatcher<T>

    Returns Matcher<T>

or

  • or<T>(...args: MaybeMatcher<T>[]): Matcher<T>
  • Type parameters

    • T

    Parameters

    • Rest ...args: MaybeMatcher<T>[]

    Returns Matcher<T>

perform

  • perform<E, F, T>(fn: (element: E, ...args: T) => void): (interactor: Interactor<E, F>, ...args: T) => Promise<void>
  • Type parameters

    • E: Element

    • F: {}

    • T: unknown[]

    Parameters

    • fn: (element: E, ...args: T) => void
        • (element: E, ...args: T): void
        • Parameters

          • element: E
          • Rest ...args: T

          Returns void

    Returns (interactor: Interactor<E, F>, ...args: T) => Promise<void>

      • (interactor: Interactor<E, F>, ...args: T): Promise<void>
      • Parameters

        Returns Promise<void>

Const read

  • read<E, F>(interactor: Interactor<E, F>, field: keyof F): Promise<FilterReturn<F>>
  • Type parameters

    • E: Element

    • F: EmptyObject

    Parameters

    Returns Promise<FilterReturn<F>>

setDocumentResolver

  • setDocumentResolver(resolver: () => Document): void
  • Parameters

    • resolver: () => Document
        • (): Document
        • Returns Document

    Returns void

setInteractorTimeout

  • setInteractorTimeout(ms: number): void
  • Parameters

    • ms: number

    Returns void

some

  • some<T>(expected: MaybeMatcher<T>): Matcher<Iterable<T>>
  • Type parameters

    • T

    Parameters

    • expected: MaybeMatcher<T>

    Returns Matcher<Iterable<T>>

Generated using TypeDoc