externalPageElements <Native_Element_Type>
Hierarchy
- MetaList<PageElement<Native_Element_Type>, PageElement<Native_Element_Type>>
- PageElements
Index
Constructors
Methods
Screenplay Pattern
Constructors
externalconstructor
Type parameters
- Native_Element_Type = any
Parameters
externalcollection: Answerable<PageElement<Native_Element_Type>[]> & ChainableMetaQuestion<PageElement<Native_Element_Type>, Question<Promise<PageElement<Native_Element_Type>[]>> | Question<PageElement<Native_Element_Type>[]>>
Returns PageElements<Native_Element_Type>
Methods
staticexternallocated
Type parameters
- NET
Parameters
externalselector: Answerable<Selector>
Returns PageElements<any>
externaldescribedAs
Changes the description of this object, as returned by
Describable.describedByandDescribable.toString.Parameters
externaldescription: Answerable<string> | MetaQuestion<PageElement<Native_Element_Type>[], Question<Promise<string>>>
Replaces the current description according to the following rules:
- If
descriptionis anAnswerable, it replaces the current description - If
descriptionis aMetaQuestion, the current description is passed ascontexttodescription.of(context), and the result replaces the current description
- If
Returns this
externaldescribedBy
Resolves the description of this object in the context of the provided
actor.Parameters
externalactor: AnswersQuestions & UsesAbilities & HasName
Returns Promise<string>
externaltoString
Returns a human-readable description of this object.
Returns string
externalforEach
Parameters
externalcallback: (current: CurrentItem<PageElement<Native_Element_Type>>, index: number, items: PageElement<Native_Element_Type>[]) => void | Promise<void>
Returns Task
externalansweredBy
Parameters
externalactor: AnswersQuestions & UsesAbilities
Returns Promise<PageElement<Native_Element_Type>[]>
externalof
Parameters
externalcontext: Answerable<PageElement<Native_Element_Type>>
Returns MetaList<PageElement<Native_Element_Type>, PageElement<Native_Element_Type>>
externaleachMappedTo
Type parameters
- Mapped_Item_Type
Parameters
externalquestion: MetaQuestion<PageElement<Native_Element_Type>, Question<Mapped_Item_Type | Promise<Mapped_Item_Type>>>
Returns MetaList<PageElement<Native_Element_Type>, Mapped_Item_Type>
externalwhere
Parameters
externalexpectation: Expectation<PageElement<Native_Element_Type>>
Returns MetaList<PageElement<Native_Element_Type>, PageElement<Native_Element_Type>>
externalcount
Returns MetaQuestionAdapter<PageElement<Native_Element_Type>, number>
externalfirst
Returns MetaQuestionAdapter<PageElement<Native_Element_Type>, PageElement<Native_Element_Type>>
externallast
Returns MetaQuestionAdapter<PageElement<Native_Element_Type>, PageElement<Native_Element_Type>>
externalnth
Parameters
externalindex: number
Returns MetaQuestionAdapter<PageElement<Native_Element_Type>, PageElement<Native_Element_Type>>
Screenplay Pattern
externalas
Maps this question's resolved answer to a QuestionAdapter of a different type.
Provide a function to transform the resolved answer:
import { Question } from '@serenity-js/core'
const number = Question.about('number returned as text', () => '42')
.as(Number)
const name = Question.about('name with whitespace', () => ' Alice ')
.as(value => value.trim())
const firstValue = Question.about('available values', () => ['first', 'second'])
.as(values => values[0])Alternatively, provide a constructor. When you call
.as(MyClass), Serenity/JS passes the resolved answer asMyClass's sole constructor argument. This is particularly useful when wrapping a mounted UI component in an Interaction Object for component testing:const card = story('components/UserCard/Default', { name: 'Alice' }).as(UserCard)To distinguish a mapping function from a constructor, Serenity/JS calls the mapping as a function first. If that throws a
TypeErrorand the mapping has aprototype(indicating an ES6 class), Serenity/JS retries withnew. This preserves the primitive result ofNumber(42), rather than producing aNumberwrapper object.Learn more
Type parameters
- O
Parameters
externalmapping: (answer: PageElement<Native_Element_Type>[]) => O | Promise<O>
A function that transforms the resolved answer, or a constructor that receives it as its sole argument.
Returns QuestionAdapter<O>
A QuestionAdapter that resolves to the mapped answer.
Uses the actor's ability to
BrowseTheWebto identify a group of Web elements located bySelector.Learn more
Actor}ListChainableMetaQuestion