Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ValuePageElementList<Store, PageElementType, PageElementOptions, ValueType>

ValuePageElementList extends PageElementList with the possibility to set, retrieve and check the values of ValuePageElements managed by ValuePageElementList.

It also adds another initial waiting condition:

  • 'value' to wait for at least one of ValuePageElementList's managed elements to have any value
template

Store type of the PageNodeStore instance which can be used to retrieve/create PageNodes

template

PageElementType type of the ValuePageElement managed by ValuePageElementList

template

PageElementOpts type of the opts parameter passed to the constructor function of the ValuePageElements managed by ValuePageElementList

template

ValueType type of the value of the ValuePageElements managed by ValuePageElementList

Type parameters

Hierarchy

  • PageElementList<Store, PageElementType, PageElementOptions>
    • ValuePageElementList

Implements

Index

Constructors

constructor

  • ValuePageElementList extends PageElementList with the possibility to set, retrieve and check the values of ValuePageElements managed by ValuePageElementList.

    It also adds another initial waiting condition:

    • 'value' to wait for at least one of ValuePageElementList's managed elements to have any value

    Parameters

    • selector: string

      an XPath expression which identifies all ValuePageElements managed by ValuePageElementList

    • opts: IValuePageElementListOpts<Store, PageElementType, PageElementOptions, ValueType>

      the options used to configure ValuePageElementList

    Returns ValuePageElementList

Properties

Protected _$

_$: Store

_$ provides access to the PageNode retrieval functions of PageElementList's PageNodeStore and prefixes the selectors of all PageNodes retrieved via _$ with the selector of PageElementList.

Protected _disableCache

_disableCache: boolean

By default, the results of an "identification process" (the last invocation of PageElementList's identify function) are cached for future invocations of PageElementList's identify function.

If _disableCache is set to true, this caching of identification results will be disabled and a new "identification process" will be performed on each invocation of PageElementList's identify function.

Disabling the identification results cache can be useful if the contents of a PageElementList change often. If the contents of a PageElementList rarely change, PageElementList's identify function can be invoked with the resetCache option set to true in order to repeat the "identification process" for a changed page content.

Protected _elementOpts

_elementOpts: PageElementOptions

the options passed to _elementStoreFunc to configure a managed PageElement instance

Protected _elementStoreFunc

_elementStoreFunc: function

This function retrieves an instance of a PageElement mapped by PageElementList from the list's PageNodeStore.

param

the XPath expression used to identify the retrieved PageElement in the DOM

param

the options used to configure the retrieved PageElement

Type declaration

    • (selector: string, options: PageElementOptions): PageElementType
    • Parameters

      • selector: string
      • options: PageElementOptions

      Returns PageElementType

Protected _identifiedObjCache

_identifiedObjCache: object

caches the last result of PageElementList's identify function for future invocations of the function

Type declaration

  • [key: string]: object
    • [key: string]: PageElementType

Protected _identifier

_identifier: IPageElementListIdentifier<Store, PageElementType>

This is the default identifier used to identify a PageElementList's managed PageElements via the key names defined in identifier's mappingObject by matching mappingObject's values with the return values of identifier's mappingFunc.

This default identifier can be overwritten by passing a custom identifier in the function parameters of PageElementList's identify function.

Protected _interval

_interval: number

the default interval used by PageElementList for all of its functions that operate with intervals (eg. wait and eventually)

Protected _lastDiff

_lastDiff: IDiff

Stores the last differences of PageNode's check state functions.

Intended for framework-internal usage only.

Protected _selector

_selector: string

the XPath selector of PageNode

Protected _store

_store: Store

an instance of PageNodeStore which can be used to retrieve/create PageNodes

Protected _timeout

_timeout: number

the default timeout used by PageElementList for all of its functions that operate with timeouts (eg. wait and eventually)

Protected _whereBuilder

_whereBuilder: ListWhereBuilder<Store, PageElementType, PageElementOptions, this>

Stores an instance of ListWhereBuilder which allows to select subsets of the PageElements managed by PageElementList by modifying the list's selector using XPath modification functions.

currently

currently: ValuePageElementListCurrently<Store, PageElementType, PageElementOptions, this, ValueType>

eventually

eventually: ValuePageElementListEventually<Store, PageElementType, PageElementOptions, this, ValueType>

Protected selector

selector: string

an XPath expression which identifies all PageElements managed by PageElementList

wait

wait: ValuePageElementListWait<Store, PageElementType, PageElementOptions, this, ValueType>

Accessors

$

  • get $(): Store

__lastDiff

  • get __lastDiff(): IDiff

all

  • get all(): PageElementType[]

elements

  • get elements(): Client<RawResult<Element[]>> & RawResult<Element[]>

first

  • get first(): PageElementType

where

  • get where(): ListWhereBuilder<Store, PageElementType, PageElementOptions, this>

Methods

__eventually

  • __eventually(func: function): boolean
  • Provides custom error handling of 'could not be located' and 'WaitUntilTimeoutError' errors for functions that check if a condition returns true within a specific timeout.

    Parameters

    • func: function

      the function which is supposed to return true within a specific timeout

        • (): void
        • Returns void

    Returns boolean

__execute

  • __execute<ResultType>(func: function): ResultType
  • Executes func and trows any errors that occur during its execution.

    If an error occurs because an element could not be located on the page, throws a custom 'could not be located' error message.

    template

    ResultType the result type of the executed function

    Type parameters

    • ResultType

    Parameters

    • func: function

      the function to be executed

        • (): ResultType
        • Returns ResultType

    Returns ResultType

    the result value of the executed function

__getNodeId

  • __getNodeId(): string

__setLastDiff

  • __setLastDiff(diff: IDiff): void

__wait

  • __wait(func: function, errorMessage: string, timeout: number): this
  • Provides custom error handling of 'could not be located' and 'WaitUntilTimeoutError' errors for functions that wait for a condition to become true within a specific timeout and throw an error if the condition does not become true.

    Parameters

    • func: function

      the function which is supposed to return true within a specific timeout and throws an error if the condition does not become true

        • (): boolean
        • Returns boolean

    • errorMessage: string

      an errorMessage that describes the condition which did not become true within a specific timeout

    • timeout: number

      the timeout used to wait for the result of the passed func to return true

    Returns this

    this (an instance of PageNode)

__waitUntil

  • __waitUntil(waitFunc: function, errorMessageFunc: function, timeout: number, interval?: number): this
  • This function executes a waitFunc until it returns true or a specific timeout is reached. If the return value of waitFunc does not become true within the timeout, this function throws a 'WaitUntilTimeoutError'.

    __waitUntil also provides custom error handling for 'could not be located' errors.

    Parameters

    • waitFunc: function

      the function which is supposed to return true within a specific timeout

        • (): boolean
        • Returns boolean

    • errorMessageFunc: function

      a function that returns an errorMessage which describes the condition that did not become true within a specific timeout

        • (): string
        • Returns string

    • timeout: number

      the timeout used to wait for the result of the waitFunc to return true

    • Optional interval: number

      the interval used to check for the result of the waitFunc to return true

    Returns this

    this (an instance of PageNode)

Protected _handleWaitError

  • _handleWaitError(error: any, errorMessage: string, timeout: number): void
  • This function implements custom error handling for 'could not be located' and 'WaitUntilTimeoutError' errors.

    Parameters

    • error: any

      an arbitrary type of error

    • errorMessage: string

      used to describe the failed condition check which caused a WaitUntilTimeoutError

    • timeout: number

      the timeout used to wait for an element to be located or for a wait condition to return true

    Returns void

Protected _includedInFilter

  • _includedInFilter(filter: any): boolean

at

  • at(index: number): PageElementType
  • Retrieves the PageElement found in the DOM at the defined index of occurrence that is identified by PageElementList's XPath selector.

    Parameters

    • index: number

      the index of occurrence in the DOM of the retrieved PageElement - STARTS AT 0

    Returns PageElementType

eachCheck

  • eachCheck<T>(elements: PageElementType[], checkFunc: function, expected?: T | T[], isFilterMask?: boolean): boolean
  • Invokes a state check function for each PageElement in a passed elements array and returns true if the result of each state check function invocation was true.

    If the passed elements array was empty, this function will always return true.

    template

    T the type of a single expected value or the type of an array element in an expected values array

    Type parameters

    • T

    Parameters

    • elements: PageElementType[]

      an array containing all PageElements for which checkFunc should be executed

    • checkFunc: function

      a state check function executed for each PageElement in elements. It is passed a PageElement as first parameter and an expected value used by the state check comparison as an optional second parameter.

        • (element: PageElementType, expected?: T): boolean
        • Parameters

          • element: PageElementType
          • Optional expected: T

          Returns boolean

    • Optional expected: T | T[]

      a single expected value or an array of expected values used for the state check comparisons

      If expected is a single value, this value is compared to each element in the array of actual values. If expected is an array of values, its length must match the length of elements and the values of its array elements are compared to the array of actual values.

    • Default value isFilterMask: boolean = false

      if set to true, the expected parameter represents a filterMask which can be used to skip the invocation of the state check function for some or all PageElements

    Returns boolean

    true if the state check functions of all checked PageElements returned true or if no state check functions were invoked at all

eachCompare

  • eachCompare<T>(elements: PageElementType[], checkFunc: function, expected?: T | T[], isFilterMask?: boolean): boolean[]
  • Invokes a state check function for each PageElement in a passed elements array and returns an array of state check function results.

    template

    T the type of a single expected value or the type of an array element in an expected values array

    Type parameters

    • T

    Parameters

    • elements: PageElementType[]

      an array containing all PageElements for which checkFunc should be executed

    • checkFunc: function

      a state check function executed for each PageElement in elements. It is passed a PageElement as first parameter and an expected value used by the state check comparison as an optional second parameter.

        • (element: PageElementType, expected?: T): boolean
        • Parameters

          • element: PageElementType
          • Optional expected: T

          Returns boolean

    • Optional expected: T | T[]

      a single expected value or an array of expected values used for the state check comparisons

      If expected is a single value, this value is compared to each element in the array of actual values. If expected is an array of values, its length must match the length of elements and the values of its array elements are compared to the array of actual values.

    • Default value isFilterMask: boolean = false

      if set to true, the expected parameter represents a filterMask which can be used to skip the invocation of the state check function for some or all PageElements. The results of skipped function invocations are not included in the total results array.

    Returns boolean[]

    an array of results of a state check function executed for each PageElement of elements

eachDo

  • Executes an action for each of PageElementList's managed PageElements.

    Parameters

    • action: function

      an action executed for each of PageElementList's managed PageElements

        • (element: PageElementType): any
        • Parameters

          • element: PageElementType

          Returns any

    • Optional filterMask: ListFilterMask

      can be used to skip the execution of an action for some or all PageElements

    Returns this

    this (an instance of PageElementList)

eachGet

  • eachGet<T>(elements: PageElementType[], getFunc: function, filterMask?: ListFilterMask): T[]
  • Invokes a state retrieval function for each PageElement in a passed elements array and returns an array of state retrieval function results.

    template

    T the type of an element of the results array

    Type parameters

    • T

    Parameters

    • elements: PageElementType[]

      an array containing all PageElements for which getFunc should be executed

    • getFunc: function

      a state retrieval function executed for each PageElement in elements. It is passed a PageElement as first parameter.

        • (element: PageElementType): T
        • Parameters

          • element: PageElementType

          Returns T

    • Optional filterMask: ListFilterMask

      can be used to skip the invocation of the state retrieval function for some or all PageElements. The results of skipped function invocations are not included in the total results array.

    Returns T[]

    an array of results of a state retrieval function executed for each PageElement of elements

eachSet

  • eachSet<T>(elements: PageElementType[], setFunc: function, values?: T | T[]): this
  • Invokes a setter function for each PageElement in a passed elements array.

    template

    T the type of a single setter value or the type of an array element in a setter values array

    Type parameters

    • T

    Parameters

    • elements: PageElementType[]

      an array containing all PageElements for which setFunc should be executed

    • setFunc: function

      a setter function executed for each PageElement in elements. It is passed a PageElement as first parameter and the value to be set as second parameter.

        • (element: PageElementType, value: T): PageElementType
        • Parameters

          • element: PageElementType
          • value: T

          Returns PageElementType

    • Optional values: T | T[]

      a single setter value or an array of setter values

      If values is a single value, all PageElements in the elements array are set to this value. If values is an array of values, its length must match the length of elements and all PageElements in the elements array are set to the values of the values array in the order that the PageElements were retrieved from the DOM.

    Returns this

    this (an instance of PageElementList)

eachWait

  • eachWait<T>(elements: PageElementType[], waitFunc: function, expected?: T | T[], isFilterMask?: boolean): this
  • Invokes a wait function for each PageElement in a passed elements array.

    Throws an error if the wait condition of an invoked wait function was not met within a specific timeout.

    template

    T the type of a single expected value or the type of an array element in an expected values array

    Type parameters

    • T

    Parameters

    • elements: PageElementType[]

      an array containing all PageElements for which waitFunc should be executed

    • waitFunc: function

      a wait function executed for each PageElement in elements. It is passed a PageElement as first parameter and an expected value used by the wait condition as an optional second parameter.

        • (element: PageElementType, expected?: T): PageElementType
        • Parameters

          • element: PageElementType
          • Optional expected: T

          Returns PageElementType

    • Optional expected: T | T[]

      a single expected value or an array of expected values used for the wait conditions

      If expected is a single value, this value is compared to each element in the array of actual values. If expected is an array of values, its length must match the length of elements and the values of its array elements are compared to the array of actual values.

    • Default value isFilterMask: boolean = false

      if set to true, the expected parameter represents a filterMask which can be used to skip the invocation of the wait function for some or all PageElements

    Returns this

    this (an instance of PageElementList)

getContainsDirectText

  • getContainsDirectText(directText: string | string[]): boolean[]
  • Returns the 'containsDirectText' status of all PageElements managed by PageElementList as an array after performing the initial waiting condition of each managed PageElement.

    A PageElement's 'containsDirectText' status is set to true if its actual direct text contains the expected direct text.

    A direct text is a text that resides on the level directly below the selected HTML element. It does not include any text of the HTML element's nested children HTML elements.

    Parameters

    • directText: string | string[]

      the expected direct text used in the comparisons which set the 'containsDirectText' status.

      If directText is a single value, this value is compared to each element in the array of actual values of all PageElements. If directText is an array of values, its length must match the length of PageElementList and the values of its array elements are compared to the array of actual values of all PageElements.

    Returns boolean[]

getContainsText

  • getContainsText(text: string | string[]): boolean[]
  • Returns the 'containsText' status of all PageElements managed by PageElementList as an array after performing the initial waiting condition of each managed PageElement.

    A PageElement's 'containsText' status is set to true if its actual text contains the expected text.

    Parameters

    • text: string | string[]

      the expected text used in the comparisons which set the 'containsText' status.

      If text is a single value, this value is compared to each element in the array of actual values of all PageElements. If text is an array of values, its length must match the length of PageElementList and the values of its array elements are compared to the array of actual values of all PageElements.

    Returns boolean[]

getContainsValue

  • getContainsValue(value: ValueType | ValueType[]): boolean[]
  • Returns the 'containsValue' status of all ValuePageElements managed by ValuePageElementList as an array after performing the initial waiting condition of ValuePageElementList and each managed ValuePageElement.

    A ValuePageElement's 'containsValue' status is set to true if its actual value contains the expected value.

    Parameters

    • value: ValueType | ValueType[]

      the expected value used in the comparisons which set the 'containsValue' status.

      If value is a single value, this value is compared to each element in the array of actual values of all ValuePageElements. If value is an array of values, its length must match the length of ValuePageElementList and the values of its array elements are compared to the array of actual values of all ValuePageElements.

    Returns boolean[]

getDirectText

  • Returns the direct texts of all PageElements managed by PageElementList as an array after performing the initial waiting condition of each managed PageElement.

    A direct text is a text that resides on the level directly below the selected HTML element. It does not include any text of the HTML element's nested children HTML elements.

    Parameters

    • Optional filterMask: ListFilterMask

      can be used to skip the invocation of the getDirectText function for some or all managed PageElements. The results of skipped function invocations are not included in the total results array.

    Returns string[]

getHasAnyDirectText

  • Returns the 'hasAnyDirectText' status of all PageElements managed by PageElementList as an array after performing the initial waiting condition of each managed PageElement.

    A PageElement's 'hasAnyDirectText' status is set to true if the PageElement has any direct text.

    A direct text is a text that resides on the level directly below the selected HTML element. It does not include any text of the HTML element's nested children HTML elements.

    Parameters

    • Optional filterMask: ListFilterMask

      can be used to skip the invocation of the getHasAnyDirectText function for some or all managed PageElements. The results of skipped function invocations are not included in the total results array.

    Returns boolean[]

getHasAnyText

  • Returns the 'hasAnyText' status of all PageElements managed by PageElementList as an array after performing the initial waiting condition of each managed PageElement.

    A PageElement's 'hasAnyText' status is set to true if the PageElement has any text.

    Parameters

    • Optional filterMask: ListFilterMask

      can be used to skip the invocation of the getHasAnyText function for some or all managed PageElements. The results of skipped function invocations are not included in the total results array.

    Returns boolean[]

getHasAnyValue

  • Returns the 'hasAnyValue' status of all ValuePageElements managed by ValuePageElementList as an array after performing the initial waiting condition of ValuePageElementList and each managed ValuePageElement.

    A ValuePageElement's 'hasAnyValue' status is set to true if the ValuePageElement has any value.

    Parameters

    • Optional filterMask: ListFilterMask

      can be used to skip the invocation of the getHasAnyValue function for some or all managed ValuePageElements. The results of skipped function invocations are not included in the total results array.

    Returns boolean[]

getHasDirectText

  • getHasDirectText(directText: string | string[]): boolean[]
  • Returns the 'hasDirectText' status of all PageElements managed by PageElementList as an array after performing the initial waiting condition each managed PageElement.

    A PageElement's 'hasDirectText' status is set to true if its actual direct text equals the expected direct text.

    A direct text is a text that resides on the level directly below the selected HTML element. It does not include any text of the HTML element's nested children HTML elements.

    Parameters

    • directText: string | string[]

      the expected direct text used in the comparisons which set the 'hasDirectText' status.

      If directText is a single value, this value is compared to each element in the array of actual values of all PageElements. If directText is an array of values, its length must match the length of PageElementList and the values of its array elements are compared to the array of actual values of all PageElements.

    Returns boolean[]

getHasText

  • getHasText(text: string | string[]): boolean[]
  • Returns the 'hasText' status of all PageElements managed by PageElementList as an array after performing the initial waiting condition of each managed PageElement.

    A PageElement's 'hasText' status is set to true if its actual text equals the expected text.

    Parameters

    • text: string | string[]

      the expected text used in the comparisons which set the 'hasText' status

      If text is a single value, this value is compared to each element in the array of actual values of all PageElements. If text is an array of values, its length must match the length of PageElementList and the values of its array elements are compared to the array of actual values of all PageElements.

    Returns boolean[]

getHasValue

  • getHasValue(value: ValueType | ValueType[]): boolean[]
  • Returns the 'hasValue' status of all ValuePageElements managed by ValuePageElementList as an array after performing the initial waiting condition of ValuePageElementList and each managed ValuePageElement.

    A ValuePageElement's 'hasValue' status is set to true if its actual value equals the expected value.

    Parameters

    • value: ValueType | ValueType[]

      the expected value used in the comparisons which set the 'hasValue' status

      If value is a single value, this value is compared to each element in the array of actual values of all ValuePageElements. If value is an array of values, its length must match the length of ValuePageElementList and the values of its array elements are compared to the array of actual values of all ValuePageElements.

    Returns boolean[]

getInterval

  • getInterval(): number

getIsEnabled

  • Returns the 'enabled' status of all PageElements managed by PageElementList as an array after performing the initial waiting condition of each managed PageElement.

    Parameters

    • Optional filterMask: ListFilterMask

      can be used to skip the invocation of the getIsEnabled function for some or all managed PageElements. The results of skipped function invocations are not included in the total results array.

    Returns boolean[]

getLength

  • getLength(): number

getSelector

  • getSelector(): string

getText

  • Returns the texts of all PageElements managed by PageElementList as an array after performing the initial waiting condition of each managed PageElement.

    Parameters

    • Optional filterMask: ListFilterMask

      can be used to skip the invocation of the getText function for some or all managed PageElements. The results of skipped function invocations are not included in the total results array.

    Returns string[]

getTimeout

  • getTimeout(): number

getValue

  • Returns the values of all ValuePageElements managed by ValuePageElementList as an array after performing the initial waiting condition of ValuePageElementList and each managed ValuePageElement.

    Parameters

    • Optional filterMask: ListFilterMask

      can be used to skip the invocation of the getValue function for some or all managed ValuePageElements. The results of skipped function invocations are not included in the total results array.

    Returns ValueType[]

identify

  • identify(__namedParameters?: object): object
  • This function identifies PageElements managed by PageElementList with the aid of an identifier's mappingObject and mappingFunc.

    It returns an identification results object which allows for PageElements managed by PageElementList to be accessed via the key names of mappingObject's properties. To create this results object, an "identification process" needs to be performed:

    • At first, PageElementList needs to fetch all managed PageElements from the page.
    • Then, a mappingFunc is executed on each fetched PageElement and its return value is compared to the values of mappingObject's properties.
    • If there is a match between a mappingFunc's return value and the value of a mappingObject's property, a new property is written to the results object whose key name is taken from the matched mappingObject's property and whose value is the PageElement on which mappingFunc was invoked.

    By default, the identification results object is cached for future invocations of the identify method. This behavior can be overwritten by passing a resetCache flag to the identify method.

    Disabling the identification results cache can be useful if the contents of a PageElementList change often. If the contents of a PageElementList rarely change, PageElementList's identify function can be invoked with the resetCache flag set to true in order to repeat the "identification process" for a changed page content.

    Be aware that the invocation of identify can be quite slow (if no identification result is cached yet) because PageElementList needs to fetch all managed PageElements from the page before mappingFunc can be executed on them.

    Therefore, always prefer PageElementList's where accessor to its identify method for the identification of managed PageElements. The only exception to this rule are cases in which the identification of PageElements cannot be described by the modification of an XPath selector (eg. identifying PageElements via their location coordinates on the page).

    Parameters

    • Default value __namedParameters: object = {}

    Returns object

    • [key: string]: PageElementType

init

  • init(cloneFunc: function): void
  • Use this method to initialize properties that rely on the this type which is not available in the constructor.

    Make sure that this method is invoked immediately after construction.

    Parameters

    • cloneFunc: function

      creates a copy of PageElementList which manages a subset of the original list's PageElements

        • (selector: XPath): this
        • Parameters

          Returns this

    Returns void

setIdentifier

setValue

  • setValue(values: ValueType[] | ValueType): this
  • This function sets the passed value(s) to all ValuePageElements managed by ValuePageElementList after performing the initial waiting condition of ValuePageElementList and each managed ValuePageElement.

    If values is an array, the number of list elements must match the number of passed values. The values will be assigned in the order that the list elements were retrieved from the DOM.

    Parameters

    • values: ValueType[] | ValueType

      a single value or an array of values

      If values is a single value, all managed ValuePageElements are set to this value. If values is an array of values, its length must match the length of ValuePageElementList and the managed ValuePageElements are set to the values of the values array in the order that the ValuePageElements were retrieved from the DOM.

    Returns this

    this (an instance of PageElementList)

toJSON

Generated using TypeDoc