Skip to main content

abstractPageElement <Native_Element_Type>

Uses the actor’s ability to BrowseTheWeb to identify a single Web element located by Selector.

Learn more

Implements

Index

Constructors

constructor

  • new PageElement<Native_Element_Type>(locator: Locator<Native_Element_Type, any>): PageElement<Native_Element_Type>
  • Type parameters

    • Native_Element_Type = any

    Parameters

    • locator: Locator<Native_Element_Type, any>

    Returns PageElement<Native_Element_Type>

Properties

publicreadonlylocator

locator: Locator<Native_Element_Type, any>

Methods

staticfrom

staticlocated

staticof

abstractof

  • Locates a child element that:

    • matches the given selector
    • is located within the parentElement

    Parameters

    Returns PageElement<Native_Element_Type>

abstractclosestTo

  • Traverses the element and its parents, heading toward the document root, until it finds a parent PageElement that 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())
    )
    }
    info

    This method relies on Element: closest() API, and so is only compatible with locating parent elements specified using the following CSS selectors:


    Parameters

    Returns PageElement<Native_Element_Type>

nativeElement

  • nativeElement(): Promise<Native_Element_Type>
  • An “escape hatch” providing access to the integration tool-specific implementation of a Web element.


    Returns Promise<Native_Element_Type>

toString

  • toString(): string
  • Returns string

abstractenterValue

  • enterValue(value: string | number | (string | number)[]): Promise<void>
  • Parameters

    • value: string | number | (string | number)[]

    Returns Promise<void>

abstractclearValue

  • clearValue(): Promise<void>
  • Returns Promise<void>

abstractclick

  • click(): Promise<void>
  • Returns Promise<void>

abstractdoubleClick

  • doubleClick(): Promise<void>
  • Returns Promise<void>

abstractscrollIntoView

  • scrollIntoView(): Promise<void>
  • Returns Promise<void>

abstracthoverOver

  • hoverOver(): Promise<void>
  • Returns Promise<void>

abstractrightClick

  • rightClick(): Promise<void>
  • Returns Promise<void>

abstractselectOptions

  • Parameters

    Returns Promise<void>

abstractselectedOptions

abstractattribute

  • attribute(name: string): Promise<string>
  • Parameters

    • name: string

    Returns Promise<string>

abstracttext

  • text(): Promise<string>
  • Returns Promise<string>

abstractvalue

  • value(): Promise<string>
  • Returns Promise<string>

abstractswitchTo

  • When the element represents an iframe, calling this method switches the current browsing context to the given iframe context.

    When used with other types of Web Element, calling this method will have the same result as calling Element.focus().


    Returns Promise<SwitchableOrigin>

    Returns an object that allows the caller to switch back to the previous context if needed.

    Learn more

abstractisActive

  • isActive(): Promise<boolean>
  • Resolves to true when the underlying element has focus. Otherwise, resolves to false.


    Returns Promise<boolean>

abstractisClickable

  • isClickable(): Promise<boolean>
  • Resolves to true when the underlying element can be clicked on. Otherwise, resolves to false.

    Please refer to test integration tool-specific documentation for details.


    Returns Promise<boolean>

abstractisEnabled

  • isEnabled(): Promise<boolean>
  • Resolves to true when the underlying element is not explicitly disabled

    Please refer to test integration tool-specific documentation for details.


    Returns Promise<boolean>

isPresent

  • isPresent(): Promise<boolean>
  • Returns a Promise that resolves to true when the element is present in the Document Object Model (DOM), false otherwise.


    Returns Promise<boolean>

abstractisSelected

  • isSelected(): Promise<boolean>
  • Resolves to true when the underlying element:

    Otherwise, resolves to false.


    Returns Promise<boolean>

abstractisVisible

  • isVisible(): Promise<boolean>
  • Resolves to true when the underlying element:

    • is not hidden, so doesn’t have CSS style like display: none, visibility: hidden or opacity: 0
    • is within the browser viewport
    • doesn’t have its centre covered by other elements

    Otherwise, resolves to false.


    Returns Promise<boolean>