externalabstractPageElement <Native_Element_Type>
Implements
Index
Constructors
externalconstructor
Type parameters
- Native_Element_Type = any
Parameters
externallocator: Locator<Native_Element_Type, any>
Returns PageElement<Native_Element_Type>
Properties
publicexternalreadonlylocator
Methods
staticexternalfrom
Type parameters
- NET
Parameters
externalnativeElement: NET
Returns MetaQuestionAdapter<PageElement<NET>, PageElement<NET>>
staticexternallocated
Type parameters
- NET
Parameters
externalselector: Answerable<Selector>
Returns MetaQuestionAdapter<PageElement<NET>, PageElement<NET>>
staticexternalof
Type parameters
- NET
Parameters
externalchildElement: PageElement<NET> | MetaQuestionAdapter<PageElement<NET>, PageElement<NET>>
externalparentElement: Answerable<PageElement<NET>>
Returns MetaQuestionAdapter<PageElement<NET>, PageElement<NET>>
staticexternalhtml
A static method producing a
MetaQuestionthat can be used withPageElements.eachMappedTomethod to extract the HTML of each element in a collection.Example
import { actorCalled, Log } from '@serenity-js/core'
import { Navigate, PageElement, By, Text } from '@serenity-js/web'
import { includes } from '@serenity-js/assertions'
await actorCalled('Debbie').attemptsTo(
Navigate.to('https://serenity-js.org'),
Log.the(
PageElements.located(By.css('a'))
.where(Text, includes('modular'))
.eachMappedTo(PageElement.html())
),
)Type parameters
- NET
Returns MetaQuestion<PageElement<NET>, QuestionAdapter<string>>
externalabstractof
Locates a child element that:
- matches the given selector
- is located within the
parentElement
Parameters
externalparentElement: PageElement<Native_Element_Type>
Returns PageElement<Native_Element_Type>
externalabstractclosestTo
Traverses the element and its parents, heading toward the document root, until it finds a parent
PageElementthat matches its associated CSS selector.Example
<div class="form-entry">
<input id="username" />
<ul class="warnings">
<li>Username should be an email address</li>
</ul>
</div>class Username {
static field = () =>
PageElement.located(By.id('username'))
.describedAs('username field')
private static container = () =>
PageElement.located(By.css('.form-entry'))
.describedAs('form entry container')
static warnings = () =>
PageElements.located(By.css('ul.warnings li'))
.describedAs('warnings')
.of(
Username.container().closestTo(Username.field())
)
}This method relies on Element: closest() API, and so is only compatible with locating parent elements specified using the following CSS selectors:
Parameters
externalchildElement: PageElement<Native_Element_Type>
Returns PageElement<Native_Element_Type>
Learn more
externalnativeElement
An "escape hatch" providing access to the integration tool-specific implementation of a Web element.
Returns Promise<Native_Element_Type>
externaltoString
Returns string
externalabstractenterValue
Parameters
externalvalue: string | number | (string | number)[]
Returns Promise<void>
externalabstractclearValue
Returns Promise<void>
externalabstractclick
Returns Promise<void>
externalabstractdoubleClick
Returns Promise<void>
externalabstractscrollIntoView
Returns Promise<void>
externalabstracthoverOver
Returns Promise<void>
externalabstractrightClick
Returns Promise<void>
externalabstractselectOptions
Parameters
externalrest...options: SelectOption[]
Returns Promise<void>
externalabstractselectedOptions
Returns Promise<SelectOption[]>
externalabstractattribute
Parameters
externalname: string
Returns Promise<string>
externalabstracttext
Returns Promise<string>
externalabstractvalue
Returns Promise<string>
externalabstracthtml
An instance method that resolves to the value of the
outerHTMLproperty of the underlying element.Example
import { actorCalled, Log } from '@serenity-js/core'
import { Navigate, PageElement, By } from '@serenity-js/web'
await actorCalled('Debbie').attemptsTo(
Navigate.to('https://serenity-js.org'),
Log.the(
PageElement.located(By.css('h1')).html()
),
)Returns Promise<string>
externalabstractswitchTo
When the element represents an
iframe, calling this method switches the current browsing context to the giveniframecontext.When used with other types of Web
Element, calling this method will have the same result as callingElement.focus().Returns Promise<SwitchableOrigin>
Returns an object that allows the caller to switch back to the previous context if needed.
Learn more
externalabstractisActive
Resolves to
truewhen the underlying element has focus. Otherwise, resolves tofalse.Returns Promise<boolean>
externalabstractisClickable
Resolves to
truewhen the underlying element can be clicked on. Otherwise, resolves tofalse.Please refer to test integration tool-specific documentation for details.
Returns Promise<boolean>
externalabstractisEnabled
Resolves to
truewhen the underlying element is not explicitly disabledPlease refer to test integration tool-specific documentation for details.
Returns Promise<boolean>
externalisPresent
Returns a
Promisethat resolves totruewhen the element is present in the Document Object Model (DOM),falseotherwise.Returns Promise<boolean>
externalabstractisSelected
Resolves to
truewhen the underlying element:- has a
selectedattribute for<option />elements - has a
checkedattribute for checkboxes
Otherwise, resolves to
false.Returns Promise<boolean>
- has a
externalabstractisVisible
Resolves to
truewhen the underlying element:- is not hidden, so doesn't have CSS style like
display: none,visibility: hiddenoropacity: 0 - is within the browser viewport
- doesn't have its centre covered by other elements
Otherwise, resolves to
false.Returns Promise<boolean>
- is not hidden, so doesn't have CSS style like
Uses the actor's ability to
BrowseTheWebto identify a single Web element located bySelector.Learn more
OptionalSwitchable