Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ListWhereBuilder<Store, PageElementType, PageElementOpts, ListType>

ListWhereBuilder allows to select subsets of a PageElementList (subsets of its managed PageElements) by modifying the list's selector using XPath modification functions.

template

Store type of the instance of PageNodeStore that is used by PageNodes returned by ListWhereBuilder

template

PageElementType type of instances of PageElements returned by ListWhereBuilder's retrieval functions (getXXX)

template

PageElementOpts type of opts passed to the constructors of PageElements returned by ListWhereBuilder's retrieval functions

template

ListType type of the PageElementList on which ListWhereBuilder operates

Type parameters

Hierarchy

  • ListWhereBuilder

Index

Constructors

constructor

  • ListWhereBuilder allows to select subsets of a PageElementList (subsets of its managed PageElements) by modifying the list's selector using XPath modification functions.

    Parameters

    • selector: string

      This is a raw XPath string used as root selector for all XPath modifications performed with ListWhereBuilder. It is appended to the selector of the PageElementList handled by ListWhereBuilder.

    • opts: IWhereBuilderOpts<Store, PageElementType, PageElementOpts, ListType>

      opts parameter passed to the constructor of ListWhereBuilder

    Returns ListWhereBuilder

Properties

Protected _cloneFunc

_cloneFunc: CloneFunc<ListType>

Creates a copy of ListWhereBuilder's PageElementList which manages a subset of the original list's PageElements.

template

ListType the type of the cloned PageElementList

Protected _elementOpts

_elementOpts: PageElementOpts

Opts passed to the constructor of PageElements created via ListWhereBuilder's PageNodeStore.

Protected _elementStoreFunc

_elementStoreFunc: function

A function that returns instances of a PageElements managed by ListWhereBuilder's PageElementList from the ListWhereBuilder's PageNodeStore.

param

the selector of a created PageElement

param

passed to the constructor of the created PageElements

Type declaration

    • (selector: string, opts: PageElementOpts): PageElementType
    • Parameters

      • selector: string
      • opts: PageElementOpts

      Returns PageElementType

Protected _getAllFunc

_getAllFunc: function

Returns all PageElements manages by ListWhereBuilder's PageElementList.

param

an instance of PageElementList for which all managed PageElements should be returned

Type declaration

    • (list: ListType): PageElementType[]
    • Parameters

      • list: ListType

      Returns PageElementType[]

Protected _selector

_selector: string

Stores the root selector for all XPath modifications performed with ListWhereBuilder.

Protected _store

_store: Store

An instance of PageNodeStore used by PageNodes which are returned by ListWhereBuilder.

Protected _xPathBuilder

_xPathBuilder: XPathBuilder

An instance of XPathBuilder used by ListWhereBuilder to perform XPath modifications.

Methods

append

  • append(appendedXPath: string): this
  • Appends a plain XPath string to the currently constructed XPath expression.

    Parameters

    • appendedXPath: string

      the appended plain XPath string

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

attribute

  • attribute(name: string, value?: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute whose name equals the passed name.

    Optionally, if also passing a value, the currently constructed XPath expression is further restricted to elements which have an HTML attribute whose name equals the passed name and whose value equals the passed value.

    Parameters

    • name: string

      the name of the HTML attribute used to restrict the currently constructed XPath expression

    • Optional value: string

      a value that needs to equal the value of the HTML attribute with the passed name

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

attributeContains

  • attributeContains(name: string, value: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute whose name contains the passed name.

    Optionally, if also passing a value, the currently constructed XPath expression is further restricted to elements which have an HTML attribute whose name equals the passed name and whose value contains the passed value.

    Parameters

    • name: string

      the name of the HTML attribute used to restrict the currently constructed XPath expression

    • value: string

      a value that needs to be contained by the value of the HTML attribute with the passed name

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

checked

  • checked(): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'checked'.

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

child

  • child(childSelector: string): this
  • Appends a childSelector to the currently constructed XPath expression in order to select a child element.

    After executing .child, the selected child element becomes the new "target" for all future XPath modification functions (eg. .id, .class) until the currently constructed XPath expression is reset.

    Parameters

    • childSelector: string

      a selector appended to the currently constructed XPath expression to select a child element

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

class

  • class(className?: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'class'.

    Optionally, if also passing a class name, the currently constructed XPath expression is further restricted to elements which have an HTML 'class' attribute with a value that equals the passed class name.

    Parameters

    • Optional className: string

      a class name which must equal the value of the HTML 'class' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

classContains

  • classContains(className: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'class' with a value that contains the passed class name.

    Parameters

    • className: string

      a class name which must be contained by the value of the HTML 'class' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

constraint

  • constraint(constraintSelector: string, builderFunc?: function): this
  • Adds a plain XPath constraint (eg. '[./span]') to the currently constructed XPath expression.

    Optionally, a builderFunc can be used to apply XPath modification functions to the constraint selector instead of the "outer" selector. To do so, builderFunc is passed an XPathBuilder instance configured to use constraintSelector as a new root for the currently constructed XPath expression.

    Parameters

    • constraintSelector: string

      a plain XPath constraint appended to the currently constructed XPath expression

    • Optional builderFunc: function

      can be used to apply XPath modification functions to constraintSelector

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

disabled

  • disabled(): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'disabled'.

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

getAll

  • getAll(): PageElementType[]
  • Retrieves all PageElements that refer to HTML elements in the DOM which are selected by the currently constructed XPath expression.

    Returns PageElementType[]

    an array of instances of PageElement

getAt

  • getAt(index: number): PageElementType
  • Retrieves a PageElement that refers to the HTML element in the DOM at the passed index (starting at 0) which is selected by the currently constructed XPath expression.

    Parameters

    • index: number

      the index of occurrence of an element in the DOM whose selector is defined by the currently constructed XPath expression (starting at 0)

    Returns PageElementType

    an instance of PageElement

getFirst

  • getFirst(): PageElementType
  • Retrieves a PageElement that refers to the first HTML element in the DOM which is selected by the currently constructed XPath expression.

    Returns PageElementType

    an instance of PageElement

getList

  • getList(): ListType
  • Retrieves a clone of ListWhereBuilder's PageElementList that manages a subset of the original list's PageElements selected by the currently constructed XPath expression.

    Returns ListType

    an instance of PageElementList that manages a subset of the original list's PageElements

hasChild

  • hasChild(childSelector: string, builderFunc?: function): this
  • Restricts the currently constructed XPath expression to elements which have at least one child element that matches the passed childSelector.

    Optionally, a builderFunc can be used to apply XPath modification functions to the child selector instead of the "outer" selector. To do so, builderFunc is passed an XPathBuilder instance configured to use the childSelector as a new root for the currently constructed XPath expression.

    Parameters

    • childSelector: string

      a plain XPath constraint appended to the currently constructed XPath expression

    • Optional builderFunc: function

      can be used to apply XPath modification functions to childSelector

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

id

  • id(id?: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'id'.

    Optionally, if also passing an id, the currently constructed XPath expression is further restricted to elements which have an HTML 'id' attribute with a value that equals the passed id.

    Parameters

    • Optional id: string

      an id which must equal the value of the HTML 'id' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

idContains

  • idContains(id: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'id' with a value that contains the passed id.

    Parameters

    • id: string

      an id which must be contained by the value of the HTML 'id' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

index

  • index(index: number): this
  • Restricts the currently constructed XPath expression to elements which have the passed index (starting at 1).

    The passed index defines an element's index of occurrence across all "levels/depths" of the DOM.

    Parameters

    • index: number

      an element's index of occurrence on a all "levels/depths" of the DOM - STARTS AT 1

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

levelIndex

  • levelIndex(levelIndex: number): this
  • Restricts the currently constructed XPath expression to elements which have the passed level index (starting at 1).

    The passed level index defines an element's index of occurrence on a single "level" of the DOM. Eg.: If index === 3, there must be 3 siblings on the same DOM level that match the current selector and the third one will be selected.

    Parameters

    • levelIndex: number

      an element's index of occurrence on a single "level" of the DOM - STARTS AT 1

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

name

  • name(name?: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'name'.

    Optionally, if also passing a name, the currently constructed XPath expression is further restricted to elements which have an HTML 'name' attribute with a value that equals the passed name.

    Parameters

    • Optional name: string

      a name which must equal the value of the HTML 'name' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

nameContains

  • nameContains(name: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'name' with a value that contains the passed name.

    Parameters

    • name: string

      a name which must be contained by the value of the HTML 'name' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notAttribute

  • notAttribute(name: string, value?: string): this
  • Restricts the currently constructed XPath expression to elements which do not have an HTML attribute whose name equals the passed name.

    Optionally, if also passing a value, the currently constructed XPath expression is restricted to elements which have an HTML attribute whose name equals the passed name and whose value does not equal the passed value.

    Parameters

    • name: string

      the name of the HTML attribute used to restrict the currently constructed XPath expression

    • Optional value: string

      a value that must not equal the value of the HTML attribute with the passed name

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notAttributeContains

  • notAttributeContains(name: string, value: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute whose name does not contain the passed name.

    Optionally, if also passing a value, the currently constructed XPath expression is restricted to elements which have an HTML attribute whose name equals the passed name and whose value does not contain the passed value.

    Parameters

    • name: string

      the name of the HTML attribute used to restrict the currently constructed XPath expression

    • value: string

      a value that must not be contained by the value of the HTML attribute with the passed name

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notChecked

  • notChecked(): this
  • Restricts the currently constructed XPath expression to elements which do not have an HTML attribute called 'checked'.

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notClass

  • notClass(className?: string): this
  • Restricts the currently constructed XPath expression to elements which do not have an HTML attribute called 'class'.

    Optionally, if also passing a class name, the currently constructed XPath expression is restricted to elements which have an HTML 'class' attribute with a value that does not equal the passed class name.

    Parameters

    • Optional className: string

      a class name which must not equal the value of the HTML 'class' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notClassContains

  • notClassContains(className: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'class' with a value that does not contain the passed class name.

    Parameters

    • className: string

      a class name which must not be contained by the value of the HTML 'class' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notDisabled

  • notDisabled(): this
  • Restricts the currently constructed XPath expression to elements which do not have an HTML attribute called 'disabled'.

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notId

  • notId(id?: string): this
  • Restricts the currently constructed XPath expression to elements which do not have an HTML attribute called 'id'.

    Optionally, if also passing an id, the currently constructed XPath expression is restricted to elements which have an HTML 'id' attribute with a value that does not equal the passed id.

    Parameters

    • Optional id: string

      an id which must not equal the value of the HTML 'id' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notIdContains

  • notIdContains(id: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'id' with a value that does not contain the passed id.

    Parameters

    • id: string

      an id which must not be contained by the value of the HTML 'id' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notName

  • notName(name?: string): this
  • Restricts the currently constructed XPath expression to elements which do not have an HTML attribute called 'name'.

    Optionally, if also passing a name, the currently constructed XPath expression is restricted to elements which have an HTML 'name' attribute with a value that does not equal the passed name.

    Parameters

    • Optional name: string

      a name which must not equal the value of the HTML 'name' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notNameContains

  • notNameContains(name: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'name' with a value that does not contain the passed name.

    Parameters

    • name: string

      a name which must not be contained by the value of the HTML 'name' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notSelected

  • notSelected(): this
  • Restricts the currently constructed XPath expression to elements which do not have an HTML attribute called 'selected'.

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notText

  • notText(text: string): this
  • Restricts the currently constructed XPath expression to elements whose text does not equal the passed text.

    Parameters

    • text: string

      a text which must not equal the text of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notTextContains

  • notTextContains(text: string): this
  • Restricts the currently constructed XPath expression to elements whose text does not contain the passed text.

    Parameters

    • text: string

      a text which must not be contained by the text of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notType

  • notType(type?: string): this
  • Restricts the currently constructed XPath expression to elements which do not have an HTML attribute called 'type'.

    Optionally, if also passing a type, the currently constructed XPath expression is restricted to elements which have an HTML 'type' attribute with a value that does not equal the passed type.

    Parameters

    • Optional type: string

      a type which must not equal the value of the HTML 'type' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

notTypeContains

  • notTypeContains(type: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'type' with a value does not contain the passed type.

    Parameters

    • type: string

      a type which must not be contained by the value of the HTML 'type' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

reset

  • reset(): this
  • Resets the currently processed XPath expression to the root XPath selector passed to ListWhereBuilder's constructor.

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

selected

  • selected(): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'selected'.

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

text

  • text(text: string): this
  • Restricts the currently constructed XPath expression to elements whose text equals the passed text.

    Parameters

    • text: string

      a text which must equal the text of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

textContains

  • textContains(text: string): this
  • Restricts the currently constructed XPath expression to elements whose text contains the passed text.

    Parameters

    • text: string

      a text which must be contained by the text of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

type

  • type(type?: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'type'.

    Optionally, if also passing a type, the currently constructed XPath expression is further restricted to elements which have an HTML 'type' attribute with a value that equals the passed type.

    Parameters

    • Optional type: string

      a type which must equal the value of the HTML 'type' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

typeContains

  • typeContains(type: string): this
  • Restricts the currently constructed XPath expression to elements which have an HTML attribute called 'type' with a value that contains the passed type.

    Parameters

    • type: string

      a type which must be contained by the value of the HTML 'type' attribute of elements selected by the currently constructed XPath expression

    Returns this

    the singleton instance of ListWhereBuilder storing the currently constructed XPath expression

Generated using TypeDoc